Nodejs API Server Mongo
Simple starter built with Typescrypt / Express / MongoDB and JWT Auth powered by Passport library - provided and actively supported by AppSeed App Generator. The authentication flow is based on json web tokens and passport-jwt
strategy - Inspired by other great OSS starters mentioned in the credits section.
Features:
- ✅ API Definition - the unified API structure implemented by this server
- ✅ Simple, intuitive codebase - built for beginners (can be extended with ease)
- ✅ Node JS / Express / Typescript
- ✅ Persistance:
MongoDB
- ✅ Auth: Passport /
passport-jwt
strategy - ✅
Docker
Can be used with other React Starters for a complete Full-Stack experience:
React Node JS Berry | React Node Soft Dashboard | React Node Horizon |
---|---|---|
![]() |
![]() |
![]() |
Create .env
from .env.sample
Update the file with your data.
Clone the sources
$ git clone https://github.com/app-generator/api-server-nodejs-mongo.git
$ cd api-server-nodejs-mongo
Install dependencies via NPM or Yarn
$ npm i
// OR
$ yarn
Start the API server - development mode
$ npm dev
// OR
$ yarn dev
Start the API server - for production (files served from build/build/index.js
)
$ npm start
// OR
$ yarn start
The API server will start using the PORT
specified in .env
file (default 5000)
< ROOT / src >
|
|-- config/
| |-- config.ts # Configuration
| |-- passport.ts # Define Passport Strategy
|
|-- models/
| |-- activeSession.ts # Sessions Model (Mongo)
| |-- user.ts # User Model (Mongo)
|
|-- routes/
| |-- users.ts # Define Users API Routes
|
|
|-- index.js # API Entry Point
|-- .env # Specify the ENV variables
|
|-- ************************************************************************
The Mongo URI lives in config/keys.js
... = 'mongodb://localhost/api_server_nodejs'
For a fast set up, use this POSTMAN file: api_sample
Register -
api/users/signup
POST api/users/signup
Content-Type: application/json
{
"username":"test",
"password":"pass",
"email":"test@appseed.us"
}
Login -
api/users/login
POST /api/users/login
Content-Type: application/json
{
"password":"pass",
"email":"test@appseed.us"
}
Logout -
api/users/logout
POST api/users/logout
Content-Type: application/json
authorization: JWT_TOKEN (returned by Login request)
{
"token":"JWT_TOKEN"
}
MIT @ AppSeed
This software is provided by the core AppSeed team with an inspiration from other great NodeJS starters:
- Initial verison - coded by Teo Deleanu
- Hackathon Starter - A truly amazing boilerplate for Node.js apps
- Node Server Boilerplate - just another cool starter
- React NodeJS Argon - released by Creative-Tim and ProjectData
Nodejs API Server Mongo
- provided by AppSeed App Generator