This REST API template is configured to be used with TypeScript and ES6.
- TypeScript support
- ES6 support
- MongoDB support
- Built-in register / login system
- Works with create-react-app frontend app (Under a "frontend" folder)
- Morgan pre-installed (w/ tiny output)
User register
Route: POST - /api/user/register
Body: {name: String; email: String; password: String}
User login
Route: POST - /api/user/login
Body: {email: String; password: String}
- Clone the repository
npm i
- Create a
.env
file - In the
.env
file, create the following entries:MONGO_URI=your_mongodb_uri_here
PORT=your_port_of_choice
TOKEN=your_jwt_token_secret
- Locate in the root folder of this app
- Type
npx create-react-app frontend
- Open the
package.json
file of the frontend app - Add the line
"proxy": "http://localhost:8000"
after Scripts
You have two options available.
- Running the api individually with the command
npm run server
- Running the app alongside a create-react-app application with Concurrently.
For this one is necesary to install the React application under a "frontend".
The npm run dev
script will look for the frontend folder and execute the start script alongside the server script of the API.
I've added a function called createError(next, message, status?)
that allows you to trow
an error and be catched by the error handling capabilities of expressJs. Nothing too fancy but
better than a bunch of try...catch blocks tied together
Find me at [email protected] or at my LinkedIn Profile
Created by Exequiel Mleziva - 2020