Initial Commit
This commit is contained in:
5
apps/backend/.gitignore
vendored
Normal file
5
apps/backend/.gitignore
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
node_modules
|
||||
.DS_Store
|
||||
dist
|
||||
dist-ssr
|
||||
*.local
|
||||
27
apps/backend/package.json
Normal file
27
apps/backend/package.json
Normal file
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"name": "backend",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "tsx watch src/index.ts",
|
||||
"build": "tsc",
|
||||
"start": "node dist/index.js"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"packageManager": "pnpm@10.10.0",
|
||||
"devDependencies": {
|
||||
"@tsconfig/node-ts": "^23.6.1",
|
||||
"@tsconfig/node23": "^23.0.1",
|
||||
"@types/node": "^22.15.18",
|
||||
"tsx": "^4.19.4",
|
||||
"typescript": "^5.8.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"dotenv": "^16.5.0",
|
||||
"fastify": "^5.3.3"
|
||||
}
|
||||
}
|
||||
42
apps/backend/src/index.ts
Normal file
42
apps/backend/src/index.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
import Fastify from 'fastify';
|
||||
const fastify = Fastify({
|
||||
logger: true,
|
||||
});
|
||||
|
||||
fastify.route({
|
||||
method: 'GET',
|
||||
url: '/',
|
||||
schema: {
|
||||
// request needs to have a querystring with a `name` parameter
|
||||
querystring: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
name: { type: 'string' },
|
||||
},
|
||||
required: ['name'],
|
||||
},
|
||||
// the response needs to be an object with an `hello` property of type 'string'
|
||||
response: {
|
||||
200: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
hello: { type: 'string' },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
// this function is executed for every request before the handler is executed
|
||||
preHandler: async (request, reply) => {
|
||||
// E.g. check authentication
|
||||
},
|
||||
handler: async (request, reply) => {
|
||||
return { hello: 'world' };
|
||||
},
|
||||
});
|
||||
|
||||
try {
|
||||
await fastify.listen({ port: 3000 });
|
||||
} catch (err) {
|
||||
fastify.log.error(err);
|
||||
process.exit(1);
|
||||
}
|
||||
6
apps/backend/tsconfig.json
Normal file
6
apps/backend/tsconfig.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"extends": ["@tsconfig/node23/tsconfig.json", "@tsconfig/node-ts/tsconfig.json"],
|
||||
"compilerOptions": {
|
||||
"outDir": "dist"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user