Giter VIP home page Giter VIP logo

generator-express-rest-api's Introduction

Build Status

generator-express-rest-api

Summary

This is a Yeoman generator to quick scaffold a RESTful API using expresss, cluter-service, mocha, chai, sinon, and istanbul. The structure generated follows the MVC controller/service/repository pattern.

Installing Yeoman

http://yeoman.io/learning/index.html

Windows Pre-Requisites

Python 2.7.x: https://www.python.org/downloads/

Installing Generator

> npm install -g generator-express-rest-api

Scaffolding Application

> yo express-rest-api

Scaffolding Controller, Controller Test, and Updates Route Config

> yo express-rest-api:controller

Scaffolding Service and Service Test

> yo express-rest-api:service

Scaffolding Repository and Repository Test

> yo express-rest-api:repository

Application NPM Commands

// installs everything that is required to run your new application
> npm run install-local
// runs application
> npm start
// runs application in debug mode
> npm run debug
// runs mocha tests
> npm test
// runs istanbul code coverage
> npm run test-coverage

Application Folder Structure Example

package.json
server.js
\app
\..\config
\..\settings
\..\..\settings-config.js
\..\route.config.json
\..\route-config.js
\..\worker-config.js

\..\controllers
\..\..\v1
\..\..\..\users
\..\..\..\..\users-controller.js

\..\services
\..\..\users
\..\..\..\user-service.js

\..\repositories
\..\..\users
\..\..\..\user-repository.js
\test
\..\spec
\..\mocha.opts
\..\tests.initialize.js

\..\..\controllers
\..\..\..\v1
\..\..\..\..\users
\..\..\..\..\..\users-controller.tests.js

\..\..\services
\..\..\..\users
\..\..\..\..\user-service.tests.js

\..\..\repositories
\..\..\..\users
\..\..\..\..\user-repository.tests.js

Example Application: Marvel Node API

https://github.com/trwalker/marvel-node

generator-express-rest-api's People

Contributors

javierabrego avatar trwalker 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

generator-express-rest-api's Issues

Can't install rest api in node 8 because of node inspector

Hi guys and gals,

I am testing diferent generators for express. I like yours, but when I was testing "npm run install-local" I got this error due to issues between the generator and node inspector.

This is a clean vanilla ubuntu 17.10, I am testing various recipees using vagrant.

vagrant@ubuntu1710:~/test$ yo express-rest-api
? Application Name test
? Version 1.0.0
? Application Description
? Author Eduardo
? Git Repository
? License
create package.json
create server.js
create app/config/route.config.json
create app/config/route-config.js
create app/config/worker-config.js
create app/config/settings/settings-config.js
create app/config/settings/settings.config.dev.json
create app/config/settings/settings.config.test.json
create app/config/settings/settings.config.prod.json
create test/mocha.opts
create test/tests.initialize.js
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN [email protected] No description
npm WARN [email protected] No license field.

[email protected] postinstall /home/vagrant/test/node_modules/sinon
node scripts/support-sinon.js

Have some ❤️ for Sinon? You can support the project via Open Collective:

https://opencollective.com/sinon/donate

npm WARN [email protected] No description
npm WARN [email protected] No license field.

[email protected] install-local /home/vagrant/test
npm install -g mocha & npm install -g node-inspector & npm install

/home/vagrant/.npm-global/bin/_mocha -> /home/vagrant/.npm-global/lib/node_modules/mocha/bin/_mocha
/home/vagrant/.npm-global/bin/mocha -> /home/vagrant/.npm-global/lib/node_modules/mocha/bin/mocha

added 6 packages in 3.394s

[email protected] preinstall /home/vagrant/.npm-global/lib/node_modules/node-inspector/node_modules/v8-profiler
node -e 'process.exit(0)'

[email protected] preinstall /home/vagrant/.npm-global/lib/node_modules/node-inspector/node_modules/v8-debug
node -e 'process.exit(0)'

/home/vagrant/.npm-global/bin/node-debug -> /home/vagrant/.npm-global/lib/node_modules/node-inspector/bin/node-debug.js
/home/vagrant/.npm-global/bin/node-inspector -> /home/vagrant/.npm-global/lib/node_modules/node-inspector/bin/inspector.js

[email protected] install /home/vagrant/.npm-global/lib/node_modules/node-inspector/node_modules/v8-debug
node-pre-gyp install --fallback-to-build

node-pre-gyp ERR! Tried to download(404): https://node-inspector.s3.amazonaws.com/debug/v1.0.1/node-v57-linux-x64.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for [email protected] and [email protected] (node-v57 ABI, glibc) (falling back to source compile with node-gyp)
make: Entering directory '/home/vagrant/.npm-global/lib/node_modules/node-inspector/node_modules/v8-debug/build'
CXX(target) Release/obj.target/debug/src/debug.o
make: g++: Command not found
debug.target.mk:98: recipe for target 'Release/obj.target/debug/src/debug.o' failed
make: *** [Release/obj.target/debug/src/debug.o] Error 127
make: Leaving directory '/home/vagrant/.npm-global/lib/node_modules/node-inspector/node_modules/v8-debug/build'
gyp ERR! build error
gyp ERR! stack Error: make failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:258:23)
gyp ERR! stack at emitTwo (events.js:126:13)
gyp ERR! stack at ChildProcess.emit (events.js:214:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
gyp ERR! System Linux 4.13.0-38-generic
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/home/vagrant/.npm-global/lib/node_modules/node-inspector/node_modules/v8-debug/build/debug/v1.0.1/node-v57-linux-x64/debug.node" "--module_name=debug" "--module_path=/home/vagrant/.npm-global/lib/node_modules/node-inspector/node_modules/v8-debug/build/debug/v1.0.1/node-v57-linux-x64"
gyp ERR! cwd /home/vagrant/.npm-global/lib/node_modules/node-inspector/node_modules/v8-debug
gyp ERR! node -v v8.11.1
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute '/usr/bin/node /usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/home/vagrant/.npm-global/lib/node_modules/node-inspector/node_modules/v8-debug/build/debug/v1.0.1/node-v57-linux-x64/debug.node --module_name=debug --module_path=/home/vagrant/.npm-global/lib/node_modules/node-inspector/node_modules/v8-debug/build/debug/v1.0.1/node-v57-linux-x64' (1)
node-pre-gyp ERR! stack at ChildProcess. (/home/vagrant/.npm-global/lib/node_modules/node-inspector/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack at emitTwo (events.js:126:13)
node-pre-gyp ERR! stack at ChildProcess.emit (events.js:214:7)
node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:925:16)
node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
node-pre-gyp ERR! System Linux 4.13.0-38-generic
node-pre-gyp ERR! command "/usr/bin/node" "/home/vagrant/.npm-global/lib/node_modules/node-inspector/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /home/vagrant/.npm-global/lib/node_modules/node-inspector/node_modules/v8-debug
node-pre-gyp ERR! node -v v8.11.1
node-pre-gyp ERR! node-pre-gyp -v v0.6.39
node-pre-gyp ERR! not ok
Failed to execute '/usr/bin/node /usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/home/vagrant/.npm-global/lib/node_modules/node-inspector/node_modules/v8-debug/build/debug/v1.0.1/node-v57-linux-x64/debug.node --module_name=debug --module_path=/home/vagrant/.npm-global/lib/node_modules/node-inspector/node_modules/v8-debug/build/debug/v1.0.1/node-v57-linux-x64' (1)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: node-pre-gyp install --fallback-to-build
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /home/vagrant/.npm/_logs/2018-04-26T19_31_56_787Z-debug.log
^C
vagrant@ubuntu1710:~/test$ npm install -g node-inspector

[email protected] preinstall /home/vagrant/.npm-global/lib/node_modules/node-inspector/node_modules/v8-profiler
node -e 'process.exit(0)'

[email protected] preinstall /home/vagrant/.npm-global/lib/node_modules/node-inspector/node_modules/v8-debug
node -e 'process.exit(0)'

/home/vagrant/.npm-global/bin/node-inspector -> /home/vagrant/.npm-global/lib/node_modules/node-inspector/bin/inspector.js
/home/vagrant/.npm-global/bin/node-debug -> /home/vagrant/.npm-global/lib/node_modules/node-inspector/bin/node-debug.js

[email protected] install /home/vagrant/.npm-global/lib/node_modules/node-inspector/node_modules/v8-debug
node-pre-gyp install --fallback-to-build

node-pre-gyp ERR! Tried to download(404): https://node-inspector.s3.amazonaws.com/debug/v1.0.1/node-v57-linux-x64.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for [email protected] and [email protected] (node-v57 ABI, glibc) (falling back to source compile with node-gyp)
make: Entering directory '/home/vagrant/.npm-global/lib/node_modules/node-inspector/node_modules/v8-debug/build'
CXX(target) Release/obj.target/debug/src/debug.o
make: g++: Command not found
debug.target.mk:98: recipe for target 'Release/obj.target/debug/src/debug.o' failed
make: *** [Release/obj.target/debug/src/debug.o] Error 127
make: Leaving directory '/home/vagrant/.npm-global/lib/node_modules/node-inspector/node_modules/v8-debug/build'
gyp ERR! build error
gyp ERR! stack Error: make failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:258:23)
gyp ERR! stack at emitTwo (events.js:126:13)
gyp ERR! stack at ChildProcess.emit (events.js:214:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
gyp ERR! System Linux 4.13.0-38-generic
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/home/vagrant/.npm-global/lib/node_modules/node-inspector/node_modules/v8-debug/build/debug/v1.0.1/node-v57-linux-x64/debug.node" "--module_name=debug" "--module_path=/home/vagrant/.npm-global/lib/node_modules/node-inspector/node_modules/v8-debug/build/debug/v1.0.1/node-v57-linux-x64"
gyp ERR! cwd /home/vagrant/.npm-global/lib/node_modules/node-inspector/node_modules/v8-debug
gyp ERR! node -v v8.11.1
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute '/usr/bin/node /usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/home/vagrant/.npm-global/lib/node_modules/node-inspector/node_modules/v8-debug/build/debug/v1.0.1/node-v57-linux-x64/debug.node --module_name=debug --module_path=/home/vagrant/.npm-global/lib/node_modules/node-inspector/node_modules/v8-debug/build/debug/v1.0.1/node-v57-linux-x64' (1)
node-pre-gyp ERR! stack at ChildProcess. (/home/vagrant/.npm-global/lib/node_modules/node-inspector/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack at emitTwo (events.js:126:13)
node-pre-gyp ERR! stack at ChildProcess.emit (events.js:214:7)
node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:925:16)
node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
node-pre-gyp ERR! System Linux 4.13.0-38-generic
node-pre-gyp ERR! command "/usr/bin/node" "/home/vagrant/.npm-global/lib/node_modules/node-inspector/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /home/vagrant/.npm-global/lib/node_modules/node-inspector/node_modules/v8-debug
node-pre-gyp ERR! node -v v8.11.1
node-pre-gyp ERR! node-pre-gyp -v v0.6.39
node-pre-gyp ERR! not ok
Failed to execute '/usr/bin/node /usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/home/vagrant/.npm-global/lib/node_modules/node-inspector/node_modules/v8-debug/build/debug/v1.0.1/node-v57-linux-x64/debug.node --module_name=debug --module_path=/home/vagrant/.npm-global/lib/node_modules/node-inspector/node_modules/v8-debug/build/debug/v1.0.1/node-v57-linux-x64' (1)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: node-pre-gyp install --fallback-to-build
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /home/vagrant/.npm/_logs/2018-04-26T19_36_51_082Z-debug.log

Example

Is there a full example somewhere using this structure in Expressjs? (I could only find PHP.)

I have been using the setup of Route-Controllers-Models as seen in beerlocker. So, this is very different to me. I really like the structure and some of the ideas I see in it. I just need a full example to really get a feel for the mental process behind this approach.

Thanks!

TraiLing slashes

Hi,

I was just checking out this project and noticed a typo. Where you use training slashes, I presume that it is intended to use trailing slashes instead.

Regards,

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.