Giter Club home page Giter Club logo

davellanedam / node-express-mongodb-jwt-rest-api-skeleton Goto Github PK

View Code? Open in Web Editor NEW
893.0 47.0 289.0 1.94 MB

This is a basic API REST skeleton written on JavaScript using async/await. Great for building a starter web API for your front-end (Android, iOS, Vue, react, angular, or anything that can consume an API). Demo of frontend in VueJS here: https://github.com/davellanedam/vue-skeleton-mvp

License: MIT License

JavaScript 99.20% HTML 0.48% Shell 0.32%
javascript api node express mongodb jwt postman jwt-authentication token eslint mongoose rest nodejs async-await mvp front-end testing mocha chai redis

node-express-mongodb-jwt-rest-api-skeleton's Introduction

Node.js express.js MongoDB JWT REST API - Basic Project Skeleton

Author Software License Tag Travis npm downloads Codacy Badge

Getting started

This is a basic API REST skeleton written on JavaScript using async/await. Great for building a starter web API for your front-end (Android, iOS, Vue, react, angular, or anything that can consume an API)

This project is created to help other developers create a basic REST API in an easy way with Node.js. This basic example shows how powerful and simple JavaScript can be. Do you want to contribute? Pull requests are always welcome to show more features.

Buy me a coffee

Hi! I'm Daniel Avellaneda, I'm an open source enthusiast and devote my free time to building projects in this field.

I'm the creator and maintainer of node-express-mongodb-jwt-rest-api-skeleton and vue-skeleton-mvp

These projects are a "starter web app kit" for any developer who wants to build their own app without starting from scratch: API + Frontend

Both projects have been downloaded thousands of times by web developers around the world.

I'm doing my best to provide you a good experience when using my apps, so if you like what I'm doing and wish to say "thanks!", please buy me a coffee ☕

Buy Me A Coffee

Feel free to send me a tweet https://twitter.com/davellanedam, share this with others or make a pull request

Features

  • Multiple environment ready (development, production)
  • Custom email/password user system with basic security and blocking for preventing brute force attacks.
  • Compressed responses.
  • Secured HTTP headers.
  • CORS ready.
  • Cache ready (Redis).
  • HTTP request logger in development mode.
  • i18n ready (for sending emails in multiple languages).
  • User roles.
  • Pagination ready.
  • User profile.
  • Users list for admin area.
  • Cities model and controller example.
  • Login access log with IP, browser and country location (for country it looks for the header cf-ipcountry that CloudFlare creates when protecting your website).
  • API autogenerated documentation by Postman.
  • API collection example for Postman.
  • Testing with mocha/chai for API endpoints.
  • NPM scripts for cleaning and seeding the MongoDB database.
  • NPM script for keeping good source code formatting using prettier and ESLint.
  • Use of ESLint for good coding practices.
  • Mailer example with Nodemailer and Mailgun.
  • Ability to refresh token
  • JWT Tokens, make requests with a token after login with Authorization header with value Bearer yourToken where yourToken is the signed and encrypted token given in the response from the login process.

Requirements

  • Node.js 10+
  • MongoDB 3.6+
  • Redis 5.0+

Demo

A demo of this API is located at: https://api-demo.daniel-avellaneda.com

Login credentials

email: [email protected]
password: 12345

IMPORTANT: Database resets every 30 mins like "12:00am, 12:30am, 1:00am" and so on. So anything you do with the API will be lost after a short time.

API documentation
Postman API example collection
If you want to test it don´t forget to change the server variable to:
https://api-demo.daniel-avellaneda.com

Demo is also linked to a VueJS project that shows how this API can be integrated to a frontend that is able to consume an API.
Repo is here: https://github.com/davellanedam/vue-skeleton-mvp
Running demo is here: https://vue-demo.daniel-avellaneda.com

How to install

Using Git (recommended)

  1. Clone the project from github. Change "myproject" to your project name.
git clone https://github.com/davellanedam/node-express-mongodb-jwt-rest-api-skeleton.git ./myproject

Using manual download ZIP

  1. Download repository
  2. Uncompress to your desired directory

Install npm dependencies after installing (Git or manual download)

cd myproject
npm install
npm update

Setting up environments (development or production)

  1. In the root this repository you will find a file named .env.example
  2. Create a new file by copying and pasting the file and then renaming it to just .env
  3. The file .env is already ignored, so you never commit your credentials.
  4. Change the values of the file to your environment (development or production)
  5. Upload the .env to your environment server(development or production)
  6. If you use the postman collection to try the endpoints, change value of the variable server on your environment to the url of your server, for development mode use http://localhost:3000

IMPORTANT: By default token expires in 3 days (4320 minutes set in .env.example). You can refresh token at endpoint GET /token. If everything it´s ok you will get a new token.

Mailer

To ensure the deliverability of emails sent by this API, Mailgun is used for mailing users when they sign up, so if you want to use that feature go sign up at their website https://www.mailgun.com

If you want to try a different method it´s ok, I used https://nodemailer.com for this API and they have different transport methods like: smtp.

i18n

Language is automatically detected from Accept-Language header on the request. So either you send locale manually on the request or your browser will send its default, if Accept-Language header is not sent then it will use en locale as default.

How to run

Database cleaning and seeding samples

There are 3 available commands for this: fresh, clean and seed.

npm run command
  • fresh cleans and then seeds the database with dynamic data.
  • clean cleans the database.
  • seed seeds the database with dynamic data.

Running in development mode (lifting API server)

npm run dev

You will know server is running by checking the output of the command npm run dev

****************************
*    Starting Server
*    Port: 3000
*    NODE_ENV: development
*    Database: MongoDB
*    DB Connection: OK
****************************

Running tests

It´s a good practice to do tests at your code, so a sample of how to do that in mocha/chai is also included in the /test directory

npm run test

Formatting code

Format your code with prettier by typing:

npm run format

Formatting markdown files

Format all your markdown files with remark by typing:

npm run remark

Linting code

Lint your code with ESLint by typing:

npm run lint

Usage

Once everything is set up to test API routes either use Postman or any other api testing application. Default username/password combination for login is [email protected]/12345.

API documentation

https://documenter.getpostman.com/view/487539/RWaHwoLV

Postman API example collection

You can import the example collection to Postman. To import, click the import button located and select postman-example.json located within the root directory.

Go to manage environments to create environments for development, production, etc. On each of the environments you create you will need to:

  1. Create a new key authToken and within the /login request this value is automatically updated after a successfull login through a script located in the tests tab. Each time you make a request to the API it will send Authorization header with the token value in the request, you can check this on the headers of users or cities endpoints in the Postman example.

  2. Create a second key server with the url of your server, for development mode use http://localhost:3000

This is a REST API, so it works using the following HTTP methods:

  • GET (Read): Gets a list of items, or a single item
  • POST (Create): Creates an item
  • PATCH (Update): Updates an item
  • DELETE: Deletes an item

Creating new models

If you need to add more models to the project just create a new file in /app/models/ and it will be loaded dynamically.

Creating new routes

If you need to add more routes to the project just create a new file in /app/routes/ and it will be loaded dynamically.

Creating new controllers

When you create a new controller, try to also create another folder with validations and helpers. Ex. /countries, /countries/validators and /countries/helpers. An example of this is included in the repository.

Bugs or improvements

Feel free to report any bugs or improvements. Pull requests are always welcome.

License

This project is open-sourced software licensed under the MIT License. See the LICENSE file for more information.

node-express-mongodb-jwt-rest-api-skeleton's People

Contributors

antibioticvz avatar ariadi avatar ciriak avatar davellanedam avatar depfu[bot] avatar markim avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

node-express-mongodb-jwt-rest-api-skeleton's Issues

npm test fails on Windows 10

The 'npm test' command is failing on Windows 10 displaying the following errors:

npm test
'NODE_ENV' is not recognized as an internal or external command, operable program or batch file.
npm ERR! Test failed.  See above for more details.

Steps to reproduce the behavior on Windows 10:

git clone https://github.com/davellanedam/node-express-mongodb-jwt-rest-api-skeleton.git
cd node-express-mongodb-jwt-rest-api-skeleton
cp .env.example .env
npm test

PS: I fixed the error by editing package.json like this:

    "test:unit": "cross-env NODE_ENV=test jest --coverage",
    "test:e2e": "cross-env NODE_ENV=test npm run fresh && npm run mocha",

Email Links Not Working

@davellanedam
I am registering a new user and an email has been sent, however, the verification link emailed is in the format [FRONTEND_URL]/verify/[VERIFICATION] while the verify method called by the endpoint upon clicking the link is looking for an id in the POST request.
This yields the error: {"errors":{"msg":"URL_NOT_FOUND"}}

Unit tests do not reveal this issue as the generated verification code is returned in development mode but not in production.

I believe the same applies to the Reset Password email. Please take a look.

Filter on objectid

I want to be able to search for all cities I created (for example).

If I add a 'userid' field to the cities model then I want to be able to

cities?filter=5aa1c2c35ef7a4e97b5e995b&fields=userid&limit=2&page=1

That way, I can utilise the pagination pattern built into the API.

I can add in
query['userId'] = new ObjectId(req.user.id)
to the controller but this feels like a workaround to the pattern.

Nested array of subdocuments

Hello,

If I have an array of nested documents in my model, how would you go about implementing the controller and its validation? And how would you pass the data to Postman?

Here is what my model looks like:

const LeadSchema = new mongoose.Schema(
  {
    name: {
      type: String,
      required: true
    },
.
.
.
contacts: [
      {
        firstName: {
          type: String,
        },
        lastName: {
          type: String,
        },
        title: {
          type: String,
        }
        }
      }
    ]
.
.
.

Thank you very much!

Mailgun fails for hosting in EU regions

Mailgun will fail when the app is hosted on a european server (no explicit error) due to Mailgun configuration.

To reproduce:

  • install/run the app from an EU location/server
  • try to trigger email sending (ie: register)
  • vague error in console

PS: my solution for hosting the app in the EU region:
Edit sendEmail.js like this:

  const auth = {
    auth: {
      // eslint-disable-next-line camelcase
      api_key: process.env.EMAIL_SMTP_API_MAILGUN,
      domain: process.env.EMAIL_SMTP_DOMAIN_MAILGUN
    },
    host: 'api.eu.mailgun.net'
  }

Related issue:
mailgun/mailgun-php#471

Flexible Route Authorization

Is your feature request related to a problem? Please describe.
Sometimes I find myself calling an endpoint to perform an action only to find out that I do not have the necessary permissions to perform the action. Here is the example:

  • As a non-admin user, I would like to delete my own account. However, the DELETE /users/:id endpoint is restricted to the admin role.

Describe the solution you'd like
Because the role auth is handled in the route component, I would like to see some way for the API request to go ahead if the requested resource is regarding the user him/herself but not another user.
The example here may be that user 1 is an admin and therefore able to delete all users. User 2 may be a standard user and can delete the account if the returned resource is the user's own data but not someone else's (I hope that makes sense).

Describe alternatives you've considered
N/A

Best way to check logged in user from another service?

Thanks for maintaining what looks like a great authentication api. I'm trying to setup a user service that my other api's can pass a JWT to to check if a user is authenticated. As this package uses a blocklist am I right in thinking that I need to call this central service as opposed to decrypting the JWT to get the user ID?

Would it be a case of adding a new route like the refresh token route, something like this?
router.get( '/whoami', requireAuth, roleAuthorization(['user', 'admin']), trimRequest.all )

No length verification on password when updating profile

When updating profile with PATCH /profile if you change password, there's no check on length. So if the user change password for a 3 chars word, no error is returned and then when trying to login, the verification on login works and it doesn't allows you to enter a 3 chars word as password.

app crashed - waiting for file changes before starting

[nodemon] 1.18.6
[nodemon] to restart at any time, enter rs
[nodemon] watching: .
[nodemon] starting node server.js
events.js:183
throw er; // Unhandled 'error' event
^

Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED 127.0.0.1:6379
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1191:14)
[nodemon] app crashed - waiting for file changes before starting...

Add role validation to USer creator

When creating a user, if you don't use an expected role from the user model enum then it crashes out with:

(node:8996) [DEP0106] DeprecationWarning: crypto.createDecipher is deprecated.
warning.js:27
TypeError: Cannot read property 'toObject' of undefined
at /Users/rob/Documents/Projects/oped/oped/app/controllers/users.js:42:43
at /Users/rob/Documents/Projects/oped/oped/node_modules/mongoose/lib/model.js:4732:16

To solve, add:

.isIn(['admin', 'user','superuser'])
.withMessage('USER_NOT_IN_KNOWN_ROLE'),

to the user validation in users.validate.js.

Thanks,

Rob

Update to Vue 3

Is your feature request related to a problem? Please describe.
There currently is no problem

Describe the solution you'd like
Vue has updated to major version 3. This will bring performance improvements and keep the project fresh.

Describe alternatives you've considered
We could remain at version 2, but that may not work long term

Additional context
Here's the release news for version 3 of vue:
https://news.vuejs.org/issues/186
Here's a basic guide for update from version 2 to 3:
https://dev.to/blacksonic/the-vue-3-upgrade-guide-4dc4

Confirmation emails in development

Hi Daniel, for testing purposes I modified the base controller to also send emails in development, so I can test the mailing system when developing. Just in case you think the change could be interesting to implement, here are my modifications:

app/controllers/base.js:

118 +    this.sendEmail(data, messageSent =>
119 +        messageSent
120 +          ? console.log(`Email SENT to: ${user.email}`)
121 +          : console.log(`Email FAILED to: ${user.email}`)
122 +    )

141 -      messageSent
142 -        ? console.log(`Email SENT to: ${user.email}`)
143 -        : console.log(`Email FAILED to: ${user.email}`)
146 +        messageSent
147 +            ? console.log(`Email SENT to: ${user.email}`)
148 +            : console.log(`Email FAILED to: ${user.email}`)
149     )
150    } else if (process.env.NODE_ENV === 'development') {
151      console.log(email)
152 +    this.sendEmail(data, messageSent =>
153 +        messageSent
154 +            ? console.log(`Email SENT to: ${user.email}`)
155 +            : console.log(`Email FAILED to: ${user.email}`)
156 +      )

Migrating passwords from another system

Firstly, thank you for this awesome project!!

I am trying to find a way to migrate users & passwords from a previous fullstack system that is built using node-express-mongoose-bcrypt. Your structure is far superior, and it would save me A LOT of time to mgirate.

Steps I followed:

  1. Change SALT_ROUNDS to 10, to match the old system
  2. Registered for a new user with this project
  3. Copied the password hash from the OLD mongo User collection
  4. Pasted it (using a mongo visualization tool) to this project's User collection in the password field.

When I try /login via Postman, the system crashes with this error:

TypeError: this.buildErrObject is not a function
    at user.comparePassword (/Users/w/Github/wfs/app/middleware/auth.js:16:23)
    at bcrypt.compare (/Users/w/Github/wfs/app/models/user.js:115:11)
    at /Users/w/Github/wfs/node_modules/bcrypt-nodejs/bCrypt.js:689:3
    at process._tickCallback (internal/process/next_tick.js:61:11)

Can you please weigh in on this error? Otherwise, can you please suggest the best way to migrate passwords?

Many thanks!
W

Validation results are doubled

Validation results are doubled when calling API with zero parameters.

On a post to /cities with nothing added other than bearer token for example, the following occurs:

{
    "errors": {
        "msg": [
            {
                "location": "body",
                "param": "name",
                "msg": "MISSING"
            },
            {
                "location": "body",
                "param": "name",
                "msg": "IS_EMPTY"
            }
        ]
    }
}

More error message standardization

There are some error messages to standardize as words and dashes:

app/models/userAccess.js:

     type: String,
       validate: {
         validator: validator.isEmail,
-        message: 'Not a valid email address'
+        message: 'EMAIL_IS_NOT_VALID'
       },
       lowercase: true,
       required: true

app/models/users.js:

       type: String,
       validate: {
         validator: validator.isEmail,
-        message: 'Not a valid email address'
+        message: 'EMAIL_IS_NOT_VALID'
       },
       lowercase: true,
       unique: true,

app/models/forgotPassword.js:

       type: String,
       validate: {
         validator: validator.isEmail,
-        message: 'Not a valid email address'
+        message: 'EMAIL_IS_NOT_VALID'
       },
       lowercase: true,
       required: true

Install nodemon in devDependencies

Hello Daniel, I'd suggest to install nodemon as a local dev Dependency, and run "npm run dev" without the need of install nodemon globally.

Password not hashed when updating in profile

Describe the bug
When I try to change password, the patch method on profile works, but saves the password without hashing it.

To Reproduce
Steps to reproduce the behavior:
Call http://localhost:5000/profile with
{
"password": "newpassword"
}
as body.

The result is the profile object and when you check the Mongo db, you see the password field un-hashed.

Error in the comparison of the password in the case of being different

hi dave! how much the route / login is executed, in the case that the password is different, an error is stored in the update of the loginAttempts field of the user model.

Cast to Number failed for value "NaN" at path loginAttempts

checking the model is selected: false and should be true.

    loginAttempts: {
      type: Number,
      default: 0,
      select: false
    },

    loginAttempts: {
      type: Number,
      default: 0,
      select: true
    },

Feature: Code coverage

Hey, I just found that your project currently is not use any coverage tool, I suggest adding nyc.

A way to simplify internationalization?

Very inspiring project. Thanks for posting it!

I had an idea, which may make internationalization more concise:

Right now, every place where there is internationalized text, you must include $t() around it - but this may not be necessary.

Given that Vue is a framework that automatically re-renders in response to changes in state, what if you used an approach like in this blog posting?

https://ourcodeworld.com/articles/read/395/getting-started-with-internationalization-i18n-in-react

The idea is to set the language by changing the required file path for the internationalized strings, and have a state variable depend on this change, such that components automatically update.

Its just an idea; see what you think.

Thanks again for posting this repo!

Emails with points

Hello Daniel, I've tried your code seems great, but I realized a small error, when the electronic mail that registers the user has points does not place them. Example:

[email protected]

in records records

[email protected]

completely removes any point that has the address.

why Auto add OPTIONS request to Server

Describe the bug
auto add OPTIONS request to Server

To Reproduce
Steps to reproduce the behavior:

  1. Press F12 on FireFox -> Network->XHR
  2. Go to Login by Admin
  3. Click on Delete,Add,Update
  4. See error

Screenshots
.
Screenshot from 2019-10-09 20-36-28

  • OS: [Ubuntu]

refresh token implementation

User has to relogin everytime the jwt token expires and that is a problem

so I believe implementing refresh token would be great

MognoAltas issue ?

Doubt. Since a few months ago I am a user of your repository and I have several projects in production using, in 2 of these projects I have had the same problem. Which I don't know if it's something in the code or more in the server configuration. As I mentioned it is just a query to know if the same thing has happened to someone else. The problem is that I have a connection with MongoAtlas and suddenly the connection number goes up to the limit. Attached are screenshots of two projects

image

image

I understand that it can be assumed of an increase of users using the application, but the truth is that it is not the case the number of users is relatively equal always

Thank you !

Auto-generated "model" and "controller"

Is your feature request related to a problem? Please describe.
It's not a problem. I just though about an idéa for the repo, which could improve the skeleton even more.

Describe the solution you'd like
Most of the people using your skeleton, will (mostly) start by replacing "City/Cities", or clone it manually, to create a new model and controller for "Vegetabels", or... anything else.

A solution to create a new model including controller for new item(s), would be great to see.

I'm not sure if there's 3rd-party tools, which could be integrated, to do that kind of magic?

Simple example:
"Vegetabels" are needed in the new project, and therefore I'll run through the structure, and secure that every model and controller are cloned, renamed and alligned, so it's now "Vegetabels", instead of "City/Cities".

Hereafter, I need to do the same thing in the Vue Front-End, to secure the proper handling.

If it should be done with a simple command, the workflow will be way faster, for adding the needed data-structure/handlers.

Additional context
I think it will require long time, to do a thing like this. But now I've suggested it. If there's a good way to do it today, maybe by using 3rd-party libs, that's awesome! I'm just not sure, where to start. And oh, if there is any, maybe it could be added to the documentation, too.

Thanks for awesome skeletons, for both frontend and backend.

mysql integration

HI

Thanks for the project

is there any easy way to convert this to my sql

Thanks

How to change Password via API

Hey,

I wanted to ask how to change the password of a user. I tried adding the password field in the form data using postman but it doesn't update. Is there any other way?

Thanks

event error

$ npm run dev

[email protected] dev D:\Downloads__projects\N
odeJs\Angular\node-express-mongodb-jwt-rest-api-skeleton
SET NODE_ENV=development & nodemon server.js

[nodemon] 1.18.9
[nodemon] to restart at any time, enter rs
[nodemon] watching: .
[nodemon] starting node server.js
events.js:167
throw er; // Unhandled 'error' event
^

Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED 127.0.0.
1:6379
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1113:14)
Emitted 'error' event at:
at RedisClient.on_error (D:\Downloads__projects\NodeJs\Angular\node-express
-mongodb-jwt-rest-api-skeleton\node_modules\redis\index.js:401:14)
at Socket. (D:\Downloads__projects\NodeJs\Angular\node-express-m
ongodb-jwt-rest-api-skeleton\node_modules\redis\index.js:279:14)
at Socket.emit (events.js:182:13)
at emitErrorNT (internal/streams/destroy.js:82:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:50:3)
at process._tickCallback (internal/process/next_tick.js:63:19)
[nodemon] app crashed - waiting for file changes before starting...

Util for accessing userId from token

When business logic requires a userId to do something such as create a new City, the userId should be pulled from the encrypted JWT and therefore the engineer needs easy access to that ID.

Filter on Sub Documents

how to filter data in subdocument, I have data like

"tournament": {
                "_id": "61b856a44509680799f619b6",
                "name": "Turnamen Amatir",
                "organizer": "Club Golf Indonesia",
                "venue": "Bukit Darmo Golf",
                "date": "2022-02-10T08:04:42.558Z",
                "tournamentPicture": "tournamentPicture-1640157632545.png"
            },
            "user": {
                "_id": "5aa1c2c35ef7a4e97b5e995a",
                "name": "Super Administrator",
                "city": "Bucaramanga",
                "country": "Colombia"
            },
            "pointTotal": 1

I want to filter tournament name, I tried by writing param fields=tournament.name&filter=Turnamen Amatir but always fail

Duplicate user creation flow

There are two API endpoints for user creation:

  • POST /register (doesn't require auth) [auth.register]
  • POST /users (requires Admin level auth) [user.createItem]

The only difference is that POST /users allows predefinition of the 'role' field.
From what I could understand, this solves a very niche problem of giving Admin higher authority to create accounts (by allowing one additional field). Is this all there is to this, or am I missing some important usage here? Was this the intended behaviour and difference between the two?

Not standardized response on error

When fetching data from the backend you got a response object. When there are errors the object is called 'errors' and if the errors are from validation, you get an array with the location, param, value and msg.

The problem is with POST /register, when you send an incorrect email like "asdasd@asdas" you don't get the validation error object, just a plain error object:

Object
errors: msg: "User validation failed: email: EMAIL_IS_NOT_VALID"
proto: Objec
t__proto__: Object

Instead of:

Object
errors:
msg: Array(1)
0: {location: "body", param: "email", value: "asdasd@asdas", msg: "EMAIL_IS_NOT_VALID"}
length: 1
proto: Array(0)
proto: Object
proto: Object

On the other hand, if you send an invalid email in POST /login you get the right validation error.

It's possible to standardize all errors to just get WHATEVER_WHATEVER (like IS_EMPTY)?

PassportJS based Social auth feature

Email signup and login is getting outdated lately and people prefer oAuth based logins from their existing logins. Add passport strategies for Facebook, Google, Twitter, Github.

Correct syntax for Redis cache

Hello,
Thank you for this wonderful API skeleton, it helps a lot.

Trying to enable Redis cache, I got this error:

Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED 127.0.0.1:6379

Changing connection syntax to this:

    engine: require('expeditious-engine-redis')({
      redis: {
        host: process.env.REDIS_HOST,
        port: process.env.REDIS_PORT
      }
    })

fixed the error for me.
Thank you.

Add Logout Feature to User with Code

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.