Install Node.js and NPM
Install a MongoDB server or use MongoDB Atlas
Fork or download this project and modify package.json for your new project.
Make a copy of the .env.example file and rename it to .env.
Create a new database and add the connection string in the .env file.
Install the required packages.
npm installThis installs all the dependencies with NPM.
Now your development environment should be ready to use!
Go to the root directory and start your app with this npm script.
npm run devThis starts a local server using
nodemonandts-node. The server base endpoint will behttp://127.0.0.1:3000where3000is the PORT variable you set in the.envfile.
- Install all dependencies with
npm install
- Run code syntax and format checking using
npm run lintwhich runs eslint. - Automatically fix lint errors with
npm run lint:fix.
- Run
npm run mongodbto start a local MongoDB server with it's data stored in.mongodbin the root directory. - This is very useful for unit / integration testing.
- It's always a good idea to use a separate database for testing.
- Run unit tests using
npm run test(for Windows users) ornpm run test:unix(for Mac and Linux users).
- Run
npm run devto start nodemon with ts-node. - The server base endpoint will be
http://127.0.0.1:8000where8000is the PORT variable you set in the.envfile.
- Run
npm run buildto compile all the Typescript sources and generate JavaScript files. - To start the built app located in
buildusenpm start.
| Route | Description |
|---|---|
| /api | Base endpoint |
| /api/auth/login | Auth - login endpoint |
| /api/auth/register | Auth - register endpoint |
| /api/user | Example entity endpoint - returns current logged in user |
| Name | Description |
|---|---|
| .mongodb/ | Local MongoDB server data |
| build/ | Compiled source files will be placed here |
| commands/ | Custom CLI command tools used with npm scripts |
| src/ | Source files |
| src/api/middlewares/ | Custom middlewares |
| src/api/entities/ | TypeORM Entities (Database model abstractions) |
| src/api/services/ | Service layer |
| src/config/ | The configuration file which loads env variables |
| src/database/factories | Factories generate entities with mock data |
| src/database/seeds | Seeds use factories to save mock data in the database |
| src/loaders/ | Loaders set up the app, database and dependencies |
| src/types/ *.d.ts | Custom type definitions |
| tests *.spec.ts | Unit and integration tests |
| .env.example | Environment configurations |