GithubHelp home page GithubHelp logo

diegohaz / rest Goto Github PK

View Code? Open in Web Editor NEW
1.8K 70.0 310.0 1.57 MB

REST API generator with Node.js, Express and Mongoose

License: MIT License

JavaScript 100.00%
mongoose mongodb rest rest-api yeoman-generator boilerplate jest

rest's Introduction

rest NPM version Build Status Coverage percentage

RESTful API generator using NodeJS, Express and Mongoose

πŸ“Ή Watch this video for an overview on how to use generator-rest and deploy your project to Heroku.



If you find this useful, please don't forget to star ⭐️ the repo, as this will help to promote the project.
Follow me on Twitter and GitHub to keep updated about this project and others.



Features

  • Highly customizable - You can choose what to install
  • Really RESTful - It follows the best practices
  • ES6! - Using babel
  • User registration API - Using passport (optional)
  • Social login API - Facebook, Google and GitHub (optional)
  • Password reset API - Sending emails with SendGrid API (optional)
  • Listing query strings - q, page, limit, fields etc. already provided by querymen
  • Query string validator - Using querymen
  • Request body validator - Using bodymen
  • Standard error responses - Using querymen and bodymen error handlers
  • Unit and integration tests - Using Jest
  • Continuous integration support - Using Travis CI
  • API docs generator - Using apidoc
  • Love β™₯ - Using me

Installation

First, install Yeoman and generator-rest using npm (we assume you have pre-installed node.js).

npm install -g yo
npm install -g generator-rest

Generators

Then, you can use yo to generate your project.

yo rest # generate a new project
yo rest:api # generate a new api endpoint inside your project

Commands

After you generate your project, these commands are available in package.json.

npm test # test using Jest
npm run coverage # test and open the coverage report in the browser
npm run lint # lint using ESLint
npm run dev # run the API in development mode
npm run prod # run the API in production mode
npm run docs # generate API docs

Playing locally

First, you will need to install and run MongoDB in another terminal instance.

$ mongod

Then, run the server in development mode.

$ npm run dev
Express server listening on http://0.0.0.0:9000, in development mode

If you choose to generate the authentication API, you can start to play with it.

Note that creating and authenticating users needs a master key (which is defined in the .env file)

Create a user (sign up):

curl -X POST http://0.0.0.0:9000/users -i -d "[email protected]&password=123456&access_token=MASTER_KEY_HERE"

It will return something like:

HTTP/1.1 201 Created
...
{
  "id": "57d8160eabfa186c7887a8d3",
  "name": "test",
  "picture":"https://gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0?d=identicon",
  "email": "[email protected]",
  "createdAt": "2016-09-13T15:06:54.633Z"
}

Authenticate the user (sign in):

curl -X POST http://0.0.0.0:9000/auth -i -u [email protected]:123456 -d "access_token=MASTER_KEY_HERE"

It will return something like:

HTTP/1.1 201 Created
...
{
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9",
  "user": {
    "id": "57d8160eabfa186c7887a8d3",
    "name": "test",
    "picture": "https://gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0?d=identicon",
    "email": "[email protected]",
    "createdAt":"2016-09-13T15:06:54.633Z"
  }
}

Now you can use the eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9 token (it's usually greater than this) to call user protected APIs. For example, you can create a new article API using yo rest:api and make the POST /articles endpoint only accessible to authenticated users. Then, to create a new article you must pass the access_token parameter.

curl -X POST http://0.0.0.0:9000/articles -i -d "title=Awesome Article&content=Yeah Baby&access_token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9"

It will return something like:

HTTP/1.1 201 Created
...
{
  "id": "57d819bfabfa186c7887a8d6",
  "title": "Awesome Article",
  "content": "Yeah Baby",
  "createdAt": "2016-09-13T15:22:39.846Z",
  "updatedAt":"2016-09-13T15:22:39.846Z"
}

Some endpoints are only accessible by admin users. To create an admin user, just pass the role=admin along to other data when calling POST /users.

Deploy

Here is an example on how to deploy to Heroku using Heroku CLI:

# start a new local git repository
git init

# create a new heroku app
heroku apps:create my-new-app

# add heroku remote reference to the local repository
heroku git:remote --app my-new-app

# add the MongoLab addon to the heroku app
heroku addons:create mongolab

# set the environment variables to the heroku app (see the .env file in root directory)
heroku config:set MASTER_KEY=masterKey JWT_SECRET=jwtSecret

# commit and push the files
git add -A
git commit -m "Initial commit"
git push heroku master

# open the deployed app in the browser
heroku open

The second time you deploy, you just need to:

git add -A
git commit -m "Update code"
git push heroku master

Directory structure

Overview

You can customize the src and api directories.

src/
β”œβ”€ api/
β”‚  β”œβ”€ user/
β”‚  β”‚  β”œβ”€ controller.js
β”‚  β”‚  β”œβ”€ index.js
β”‚  β”‚  β”œβ”€ index.test.js
β”‚  β”‚  β”œβ”€ model.js
β”‚  β”‚  └─ model.test.js
β”‚  └─ index.js
β”œβ”€ services/
β”‚  β”œβ”€ express/
β”‚  β”œβ”€ facebook/
β”‚  β”œβ”€ mongoose/
β”‚  β”œβ”€ passport/
β”‚  β”œβ”€ sendgrid/
β”‚  └─ your-service/
β”œβ”€ app.js
β”œβ”€ config.js
└─ index.js

src/api/

Here is where the API endpoints are defined. Each API has its own folder.

src/api/some-endpoint/model.js

It defines the Mongoose schema and model for the API endpoint. Any changes to the data model should be done here.

src/api/some-endpoint/controller.js

This is the API controller file. It defines the main router middlewares which use the API model.

src/api/some-endpoint/index.js

This is the entry file of the API. It defines the routes using, along other middlewares (like session, validation etc.), the middlewares defined in the some-endpoint.controller.js file.

services/

Here you can put helpers, libraries and other types of modules which you want to use in your APIs.

TODO

  • Support optional phone authentication
  • Support optional email confirmation process
  • Support Twitter and other social login methods
  • Socket.io support

PRs are welcome.

Credits

@QzSG and all contributors

License

MIT Β© Diego Haz

rest's People

Contributors

ashiknesin avatar cwang1221 avatar diegohaz avatar drochag avatar emilguareno avatar jorgeluisrezende avatar kbzowski avatar kdschaffe avatar kiliczsh avatar lobosque avatar maustand avatar mlevin2 avatar nickhingston avatar nntin avatar pedro-victor avatar qzsg avatar ridhamtarpara avatar tsauzeau 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rest's Issues

Override limit 100

What's the easiest way to override the limit of 100 for an api? I think this is coming form your other lib querymen but I am not really sure how to override it. It looks like maybe I can do this in the router, or the model, or?

When I try to set a limit greater than 100 I get:

logs?limit=101

{
  "name": "max",
  "param": "limit",
  "value": 101,
  "max": 100,
  "valid": false,
  "message": "limit must be lower than or equal to 100"
}

curl -d not found

Hello,

I'm trying to sign in with curl into the API

curl -X POST http://0.0.0.0:9000/auth -i -u [email protected]:123456 -d "access_token=MASTER_KEY_HERE"

But its not working, returns me an error saying that: -d command not found

Do i need to update something? (i've already updated curl)

Uploading images?

How would I go about uploading images? Currently I'm just uploading base64 encoded data

returned data should not be at the top-level or the json response

I know this could be easily dismissed as "a matter of taste", but I just wanted to mention that returning the model data at the top level of the json document hierarchy is considered a bit of an antipattern and something that I see other open source codebases moving away from.

I don't remember where I last saw this matter discussed but a quick 1 minute google search I was able to find a couple of guidelines around which corroborate this approach:

https://google.github.io/styleguide/jsoncstyleguide.xml?showone=data#data

and also:

http://jsonapi.org/format/#document-top-level

Testing on Windows

I've found some problems when trying to npm test on Windows.

First, npm run lint tries to lint package.json files, which obviously throws. The solution would be changing the script to: "lint": "eslint <%= srcDir %>/**/*.js" on https://github.com/diegohaz/generator-rest/blob/master/generators/app/templates/_package.json#L14

Another problem is the test script itself. It has a condition written in shell script and Windows doesn't recognize it. I'm looking for a cross-platform conditional statement solution, but found nothing yet.

Payload to large

Hi, when adding an object to the server, I get an error stating the payload is to large to add. I know what it is and I know how to fix it with these 2 lines.

app.use(bodyParser.json({ limit: '50mb', type: 'application/json' }))
app.use(bodyParser.urlencoded({ limit: '50mb', extended: true, parameterLimit: 50000 }))

I have overcome this problem on a previous server but I am struggling to get it to work with your sever which I am loving at the moment. Where I previously added these lines is in the index.js file where you export the "app" but It's not working.

Any advice?

Change user model

As we add more auth providers (facebook, google, twitter etc.), I'm thinking of joining them in a single field, like services:

const UserSchema = new Schema({
  email: {
    type: String,
    match: /^\S+@\S+\.\S+$/,
    required: true,
    unique: true,
    trim: true,
    lowercase: true
  },
  password: {
    type: String,
    minlength: 6
  },
  services: {
    facebook: String,
    twitter: String,
    google: String,
    github: String
  },
  name: {
    type: String,
    index: true,
    trim: true
  },
  role: {
    type: String,
    enum: roles,
    default: 'user'
  },
  picture: {
    type: String,
    trim: true
  }
}, {
  timestamps: true
})

For Facebook, we just need to store the user id. I also don't know if it will be the same with twitter, google etc.

Validation

I've been playing around with validation for most of the inputs that are going through mongoose, I'm just wondering if there is going to be at any time some built in validation within the service? That being a lot quicker since some of it would already be generated, or it being simpler to implement.

Terminations missing

On many places the terminatios are is missing which causes warnings in my IDE (ending lines with ;).

This looks optimizable from my POV.

Was there a reason to leave those?
If not maybe I can help you to do a cleanup here.

Model generation from yo rest:api

While using the yo:rest api tool to create an endpoint, when you get to the model generation part, it asks for a comma separated list of your fields. Is there a way to provide a model that has nested fields/arrays in this setup process?

For example:

-id
-colors
----color_name
----color_value
-categories
---category_name
---category_slug

...and so on.

Inconsistent Naming Convention Of Generated API

I Generated a sample API on an existing project with "yo rest:api" which resulted to the files named as indicated:
screen shot 2016-11-04 at 6 59 58 pm

Wondering if this is an upgrade, or something i'm yet to do as compared to this:
screen shot 2016-11-04 at 6 52 28 pm

Thanks.

Update nock

Steps

On generator's root:

yarn upgrade nock

On template's package.json

"nock": "^9.0.2",

I'm just leaving it here in the case of someone wants to contribute. πŸŽ‰

Travis CI errors

There're strange errors on CI that occur sometimes and break the tests. I think it's related to the integration between Mockgoose and AVA.

image
image
image

I don't know yet how to solve it, even though it's not a big problem. The solution, for now, is just restarting the build on Travis CI.

Query the database

Hey man.

I see that when generating a new api, the get request that one can make with the master key etc it will return all the indexes/values. My question is I see with the get a query function is passed through

router.get('/', master(), query(), index)

Now my question that I have is can I make a custom query sent from the client side with a get request to return only the desired values from the query?

Login

I created a client app in Angular js, in this app you can log in as an user and add articles. I merge my client with this server. I tried to log in with the user created in the terminal and everything i used (add Authorization: Bearer Access-Token in header request) i got this:
Request URL:http://0.0.0.0:9000/auth
Request Method:POST
Status Code:401 Unauthorized
Remote Address:0.0.0.0:9000

I used $http service.

Can you give me some advices?ο»Ώ

API files don't get linted by Atom/Sublime linter

It happens because the linter searches for a .eslintrc or a package.json file recursively starting in the current file path. The API folder has a package.json file, but this doesn't include an eslintConfig property, so it disables the linter.

Possible solutions:

  • remove package.json from API folders;
  • add eslintConfig to each package.json folder;
  • add a .eslintrc file to the root directory.

I think the last one is the better solution.

Update bcrypt

Now it supports promises natively: https://github.com/kelektiv/node.bcrypt.js#with-promises

No need for promisifying this anymore.

Steps:

On generator's root:

yarn upgrade bcrypt

On template's api/user/model.js:

Remove this:

<%_ if (passwordSignup) { _%>
const compare = require('bluebird').promisify(bcrypt.compare)
<%_ } _%>

On userSchema.pre hook, change bcrypt.hash to promise:

bcrypt.hash(this.password, rounds).then((hash) => {
    this.password = hash
    next()
  }).catch(next)

Change compare to bcrypt.compare on authenticate method:

return bcrypt.compare(password, this.password).then((valid) => valid ? this : false)

On template's package.json, update bcrypt's version:

"bcrypt": "^1.0.1",

Thoughts on GraphQL

Some people are asking me about GraphQL support. I don't have much experience with it. But, as far as I know (please, correct me if I'm wrong), REST and GraphQL are two different approaches and can not coexist.

I'm working on some projects that would benefit from a GraphQL API, so I'm very into learning it and perhaps creating/using another generator or integrating it on generator-rest (if it's possible).

Just creating this thread to see if there're more people interested on this.

cc @cameronroe @arraisgabriel

Create a README in the generated project

Currently the README is the documentation generated by npm run docs, which could be in a DOCS.md file. It should put another useful info in the README (including a link to DOCS).

TypeError: request.body.hasOwnProperty is not a function

When I attempt to make a post request to one of my own api endpoint that I have generated, I'm continuing to get this below response. I think I'm using the API correctly I've followed along with the documentation a few times and it continues to occur.

TypeError: request.body.hasOwnProperty is not a function at JwtStrategy.<anonymous> (/Users/~/Documents/Development/Websites/servers-rest/node_modules/passport-jwt/lib/extract_jwt.js:30:42) at JwtStrategy._jwtFromRequest (/Users/~/Documents/Development/Websites/servers-rest/node_modules/passport-jwt/lib/extract_jwt.js:82:39) at JwtStrategy.authenticate (/Users/~/Documents/Development/Websites/servers-rest/node_modules/passport-jwt/lib/strategy.js:84:22) at attempt (/Users/~/Documents/Development/Websites/servers-rest/node_modules/passport/lib/middleware/authenticate.js:348:16) at authenticate (/Users/~/Documents/Development/Websites/servers-rest/node_modules/passport/lib/middleware/authenticate.js:349:7) at /Users/~/Documents/Development/Websites/servers-rest/src/services/passport/index.js:26:3 at Layer.handle [as handle_request] (/Users/~/Documents/Development/Websites/servers-rest/node_modules/express/lib/router/layer.js:95:5) at next (/Users/~/Documents/Development/Websites/servers-rest/node_modules/express/lib/router/route.js:131:13) at Route.dispatch (/Users/~/Documents/Development/Websites/servers-rest/node_modules/express/lib/router/route.js:112:3) at Layer.handle [as handle_request] (/Users/~/Documents/Development/Websites/servers-rest/node_modules/express/lib/router/layer.js:95:5) at /Users/~/Documents/Development/Websites/servers-rest/node_modules/express/lib/router/index.js:277:22 at Function.process_params (/Users/~/Documents/Development/Websites/servers-rest/node_modules/express/lib/router/index.js:330:12) at next (/Users/~/Documents/Development/Websites/servers-rest/node_modules/express/lib/router/index.js:271:10) at Function.handle (/Users/~/Documents/Development/Websites/servers-rest/node_modules/express/lib/router/index.js:176:3) at router (/Users/~/Documents/Development/Websites/servers-rest/node_modules/express/lib/router/index.js:46:12) at Layer.handle [as handle_request] (/Users/~/Documents/Development/Websites/servers-rest/node_modules/express/lib/router/layer.js:95:5) at trim_prefix (/Users/~/Documents/Development/Websites/servers-rest/node_modules/express/lib/router/index.js:312:13) at /Users/~/Documents/Development/Websites/servers-rest/node_modules/express/lib/router/index.js:280:7 at Function.process_params (/Users/~/Documents/Development/Websites/servers-rest/node_modules/express/lib/router/index.js:330:12) at next (/Users/~/Documents/Development/Websites/servers-rest/node_modules/express/lib/router/index.js:271:10) at Function.handle (/Users/~/Documents/Development/Websites/servers-rest/node_modules/express/lib/router/index.js:176:3) at router (/Users/~/Documents/Development/Websites/servers-rest/node_modules/express/lib/router/index.js:46:12)

constrain users access to only their own personal data

Regarding user access endpoints ( not related to admin/masterkey):

Correct me if I'm wrong, but it looks to me that the authentication and routing code currently has no built in mechanism for pΕ•eventing an authenticated user from accessing data related to other users by simply leveraging querymen to make queries that pass some other user's id ?

Hopefully I just failed to locate this, but in case it really doesn't exist, and because this is such a common requirement, it would be great to include a build-in mechanism for this so that this functionality could be activated by just adding an item or attribute ( could be named something like requireOwnId or ownerOnly ) to a route's middleware chain.

Support for model relations

Hey. Could support for model relations be added, so we could be able to use the generator to have endpoints like GET books/{id}/pages?

Make tests optional

For those who don't want to generate the *.test.js files or want to use another test library and create them by their own.

Rename the api file names

It should look more like:

api
β”œβ”€β”€ user
β”‚Β Β  β”œβ”€β”€ api.js
β”‚Β Β  β”œβ”€β”€ api.test.js
β”‚Β Β  β”œβ”€β”€ controller.js
β”‚Β Β  β”œβ”€β”€ index.js
β”‚Β Β  β”œβ”€β”€ model.js
β”‚Β Β  └── model.test.js
└── index.js

Where api/user/api.js is the current api/user/user.router.js. I think it still makes sense while gives a better tree (since api comes alphabetically first).

The api/index.js file is the current routes.js file.

Also, this makes easier to change the endpoint names as one no longer needs to update the name of each file.

The api/user/index.js file should look like:

export api from './api'
export controller from './controller'
export model, { schema } from './model'

Skipping sendgrid information prompt crashes the dev server with missing module error

This apparently happens if you choose to generate a password reset endpoint but skip the sendgrid information prompt.
Not sure if this is expected behavior, but maybe it would be best to use placeholder information instead of not creating the module altogether?

I'm just thinking that the user might want to generate the code while not having their sendgrid information at hand.

module.js:457
    throw err;
    ^

Error: Cannot find module './api/password-reset'
    at Function.Module._resolveFilename (module.js:455:15)

TypeError: request.body.hasOwnProperty is not a function

Post a new Article

curl -X POST http://0.0.0.0:9000/articles -i -d "title=Awesome Article&content=YeahBaby access_token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9"

TypeError: request.body.hasOwnProperty is not a function at JwtStrategy.<anonymous> (.../node_modules/passport-jwt/lib/extract_jwt.js:30:42)

Only on local version. It works on heroku. Any Idea?

Versions

IOS: 10.12
npm: 3.10.9
nodejs: 6.3.1
MongoDB: 3.2.8
passport-jwt "^2.1.0"

Angular 2 Basic Auth

Hi, how would you send the request from the client side using angular 2 to authenticate the user and then send back the token with all the relevant details of the user?

I've tried searching and it looks like you'll need to add headers to the post from the client side but not sure how to do that. Can you maybe give me an example?

Auth0

Can this work with auth0?

Appropriate usage of master key

I'm fairly new to the concept of a master key. To me it makes sense as a "the dev who has this can get anything done", but by default it's middleware on the /auth endpoint and user creation. If I were to have a site that allows users to register themselves and to log themselves in... wouldn't that mean that they would need to have the master key stored locally? Am I misinterpreting how the master key is used? My understanding would be that both of these endpoints should have no authorization middleware.

Should I remove these from these two endpoints if that is the case?

Update babel-jest and jest-cli

Steps:

On generator's root:

yarn upgrade babel-jest jest-cli 

On template's package.json

"setupTestFrameworkScriptFile": "<rootDir>/test/setup.js"
...
"babel-jest": "^18.0.0",
...
"jest-cli": "^18.0.0",

multi-language support

Currently response strings are hardcoded, so creating a project for non-English users requires to carefully search and replace all user facing text.

At least having all text strings centralized in a single location would make this task much easier and less error prone.

Side note: Let me know what is the best way for me to contribute with suggestions like this. Maybe a
Product Pains page would be a better option as not to clutter the issues page with these enhancement requests.

Update rand-token

Steps

On generator's root:

yarn upgrade rand-token

On template's package.json

"rand-token": "^0.3.0",

I'm just leaving it here in the case of someone wants to contribute. πŸŽ‰

Update dotenv-safe

Steps

On generator's root:

yarn upgrade dotenv-safe

On template's package.json

"dotenv-safe": "^3.0.0",

I'm just leaving it here in the case of someone wants to contribute. πŸŽ‰

With this, everything will be up to date. πŸ™Œ

Remove passport-jwt dependency

Look for an alternative to that. The project is awesome, but seems unmaintained. There're old PRs unmerged (even people asking for that), like one we need, and the owner doesn't answer.

Transpile on the fly

As it will only run on the server, it doesn't need to be transpiled to dist and the root directory can be deployed as well.

implementing logout?

The generator generates code for creating users, logging in, but nothing for logging out/ destroying the session.

Is there a recommended approach?

send email confirmation to validate user registration

It looks like sendgrid is currently only used to reset user passwords. If that is the case it would be nice to have it also used to send a confirmation email upon user registration, so that it can be properly validated.

I suppose this would require the use of a unique email validation token.

Add an option to name the user model something else

Just getting started testing this codebase but it already looks awesome from the get go. :-)
To make it even more awesome, it would be great to add an option to name the User model something else.

For reference, KeystoneJS has this feature on their generator, btw.

The reasoning is that a lot of projects, such as the one I'm working now, support multiple api users under the same paying account, so to model this, instead of a User model I have an Account model (which is the equivalent to the user model you have) and a Profile model instead.

Error on installing dependencies

I am getting error on entering yo rest . It installs dependencies but towards the end it gives error.

I am using windows 8.1

npm ERR! Windows_NT 6.3.9600
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Thomas\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "intall"
npm ERR! node v6.9.1
npm ERR! npm  v3.10.6
npm ERR! path C:\Users\Thomas\my-api\node_modules\.staging\jsonpointer-10566ae3
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall rename

npm ERR! Error: EPERM: operation not permitted, rename 'C:\Users\Thomas\my-api\node_modules\.staging\jsonpointer-10566ae3' -> 'C:\User\Thomas\my-api\node_modules\jsonpointer'
npm ERR!     at destStatted (C:\Users\Thomas\AppData\Roaming\npm\node_modules\npm\lib\install\action\finalize.js:25:7)
npm ERR!     at FSReqWrap.oncomplete (fs.js:123:15)
npm ERR!
npm ERR! Error: EPERM: operation not permitted, rename 'C:\Users\Thomas\my-api\node_modules\.staging\jsonpointer-10566ae3' -> 'C:\User\Thomas\my-api\node_modules\jsonpointer'
npm ERR!     at Error (native)
npm ERR!  { Error: EPERM: operation not permitted, rename 'C:\Users\Thomas\my-api\node_modules\.staging\jsonpointer-10566ae3' -> 'C:\Uers\Thomas\my-api\node_modules\jsonpointer'
npm ERR!     at destStatted (C:\Users\Thomas\AppData\Roaming\npm\node_modules\npm\lib\install\action\finalize.js:25:7)
npm ERR!     at FSReqWrap.oncomplete (fs.js:123:15)
npm ERR!
npm ERR! Error: EPERM: operation not permitted, rename 'C:\Users\Thomas\my-api\node_modules\.staging\jsonpointer-10566ae3' -> 'C:\User\Thomas\my-api\node_modules\jsonpointer'
npm ERR!     at Error (native) parent: 'my-api' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\Users\Thomas\my-api\npm-debug.log

Can't retrieve data from db.

1.Create project and install npm.
2.Start mongo db.
3.Use postman to retrieve "users" "GET" http://0.0.0.0:9000/users
3.1 try to add access_token behind URL (default MASTER_KEY)
3.2 try to add access_token in headers (default MASTER_KEY)

Result: 401 unauthorized
Expect: empty array.

Support Github login

The same way Facebook login was implemented, we need to:

It's important to note that the API will only handle the token provided by Github and not the entire OAuth process (it must be done on the client).

This issue is participating on the Digital Ocean's Hacktoberfest.

Package.json question

I was curious on the reason/purpose to have a package.json file under each api module folder? Tried finding an answer/example online and seen a couple others do the same but never found explanation.

Thanks;

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.