Deploy a Node.js server very quickly with Fastify and MongoDB.
- 📁 dist/
- 📁 node_modules/
- 📂 src/
- 📁 controllers/
- 📂 types/
- 📄 index.type.ts
- 📂 routes/
- 📄 index.route.ts
- 📂 services/
- 📄 index.service.ts
- 📄 aws.service.ts
- 📄 emailer.service.ts
- 📄 fastify.service.ts
- 📄 firebase.service.ts
- 📄 redis.service.ts
- 📄 mongo.service.ts
- 📄 index.ts
- 📄 example.env
- 📄 package.json
- 📄 postman.json
- 📄 README.md
- 📄 tsconfig.json
- 📄 yarn.lock
First of all, install typescript and nodemon gobally with yarn.
- At the repository root, download the dependencies with yarn:
yarn
-
Rename the file example.env to .env, and edit the environment variables. Some of them are required when using Fastify and TypeORM as
JWT_SECRET
,SERVER_PORT
andMONGO_
ones. -
Make sure you're running your database service. Create your collection types in types/index.type.ts.
-
Add aditional services at index.ts services array, if necessary.
-
Add aditional *.route.ts files into index.route.ts routes array, if necessary.
-
Run tsc -w at project root directory.
-
Additionally, run nodemon at dist/ directory.
-
Edit src/ TypeScript code with automatic reload!