Giter Club home page Giter Club logo

nodetyped's Introduction

NodeTyped

A Node.js starter kit featuring ES6 with Secuential Asynchrony (async/await), Express (Routing middlewares, Web, Api), Typescript, Mongoose, SCSS, EJS, Nodemon, Bootstrap 4, TSLint, TypeDoc, .

  • Simple npm setup and maintenance, without grunt/gulp/webpack/...

  • Support for async/await

Example middleware:

async function(req, res, next) {
    let title = 'NodeTyped Express';
    try {
        let data = await readFile(file, 'utf-8');
        res.render('index', { title: title, dump: data });
    } catch (e) {
        next(e);
    }
}

Requirements

Make sure you have node version >= 8.0

Clone and Install dependencies

# clone the repo
# --depth 1 removes all but one .git commit history
git clone --depth 1 https://github.com/jamg44/NodeTyped.git projectname

# change directory to your new project
cd projectname

# install the repo dependencies with npm
npm install

# start the server
npm run dev

If you want to use mongoose models, start mongodb, check localConfig.js and:

# load sample products in database (defaults to 'test')
npm run loadMocks

Develop

Watch mode

You can start the server in development mode (linter included) with:

npm run dev

Open the browser at:

Start MongoDB, run 'npm run loadMocks', and check:

As you save in your editor, the compiler will rebuild and restart the server.

Other commands

Run the linter manually:

npm run lint

Clean temp folders:

npm run clean

Run the tests:

npm test

Generate docs, the output will be in /doc folder:

npm run doc

Production / Integration

To run the project in a server you'll want to run the built code instead src version.

# deploy the repo to server and run
npm install
npm start

Recommendations

  • To change project name update package.json
"name": "project_name", <-----
...
"dev": "tsc && DEBUG=project_name2:* ... <-----
  • All your functions should return promises for better use with async/await.
let readFile = function(file, encoding) => {
    return new Promise((resolve, reject) => {
        fs.readFile(file, encoding, function(err, data) {
            if (err) {
                return reject(err);
            }
            resolve(data);
        });
    });
};

Roadmap (TODO)

  • API authentication with JWT
  • Add cluster
  • User system (register, login, etc)
  • Add tests
  • Basic panel

License

MIT

Made with ♡ by Javier Miguel González @javiermiguelg

nodetyped's People

Contributors

jamg44 avatar rammiro82 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

Watchers

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

nodetyped's Issues

question not a bug

I am new to API this is safe to use for production?
What are the benefits of having both API and normal render views?

Cannot download "https://github.com/sass/node-sass/releases/download/v3.13.1/win32-x64-57_binding.node"

I am getting this error after npm install:

$ npm install

npm WARN deprecated [email protected]: Please update to minimatch 3.0.2 or higher                                                                                                                 to avoid a RegExp DoS issue

> [email protected] install C:\Users\HP\Desktop\nodebook\projectname\node_modules                                                                                                                \node-sass
> node scripts/install.js

Downloading binary from https://github.com/sass/node-sass/releases/download/v3.1                                                                                                                3.1/win32-x64-57_binding.node
Cannot download "https://github.com/sass/node-sass/releases/download/v3.13.1/win                                                                                                                32-x64-57_binding.node":

HTTP error 404 Not Found

Hint: If github.com is not accessible in your location
      try setting a proxy via HTTP_PROXY, e.g.

      export HTTP_PROXY=http://example.com:1234

or configure npm proxy via

      npm config set proxy http://example.com:8080

> [email protected] postinstall C:\Users\HP\Desktop\nodebook\projectname\node_mod                                                                                                                ules\node-sass
> node scripts/build.js

Building: C:\Program Files\nodejs\node.exe C:\Users\HP\Desktop\nodebook\projectn                                                                                                                ame\node_modules\node-gyp\bin\node-gyp.js rebuild --verbose --libsass_ext= --lib                                                                                                                sass_cflags= --libsass_ldflags= --libsass_library=
gyp info it worked if it ends with ok
gyp verb cli [ 'C:\\Program Files\\nodejs\\node.exe',
gyp verb cli   'C:\\Users\\HP\\Desktop\\nodebook\\projectname\\node_modules\\nod                                                                                                                e-gyp\\bin\\node-gyp.js',
gyp verb cli   'rebuild',
gyp verb cli   '--verbose',
gyp verb cli   '--libsass_ext=',
gyp verb cli   '--libsass_cflags=',
gyp verb cli   '--libsass_ldflags=',
gyp verb cli   '--libsass_library=' ]
gyp info using [email protected]
gyp info using [email protected] | win32 | x64
gyp verb command rebuild []
gyp verb command clean []
gyp verb clean removing "build" directory
gyp verb command configure []
gyp verb check python checking for Python executable "python2" in the PATH
gyp verb `which` failed Error: not found: python2
gyp verb `which` failed     at getNotFoundError (C:\Users\HP\Desktop\nodebook\pr                                                                                                                ojectname\node_modules\which\which.js:13:12)
gyp verb `which` failed     at F (C:\Users\HP\Desktop\nodebook\projectname\node_                                                                                                                modules\which\which.js:68:19)
gyp verb `which` failed     at E (C:\Users\HP\Desktop\nodebook\projectname\node_                                                                                                                modules\which\which.js:80:29)
gyp verb `which` failed     at C:\Users\HP\Desktop\nodebook\projectname\node_mod                                                                                                                ules\which\which.js:89:16
gyp verb `which` failed     at C:\Users\HP\Desktop\nodebook\projectname\node_mod                                                                                                                ules\isexe\index.js:42:5
gyp verb `which` failed     at C:\Users\HP\Desktop\nodebook\projectname\node_mod                                                                                                                ules\isexe\windows.js:36:5
gyp verb `which` failed     at FSReqWrap.oncomplete (fs.js:152:21)
gyp verb `which` failed  python2 { Error: not found: python2
gyp verb `which` failed     at getNotFoundError (C:\Users\HP\Desktop\nodebook\pr                                                                                                                ojectname\node_modules\which\which.js:13:12)
gyp verb `which` failed     at F (C:\Users\HP\Desktop\nodebook\projectname\node_                                                                                                                modules\which\which.js:68:19)
gyp verb `which` failed     at E (C:\Users\HP\Desktop\nodebook\projectname\node_                                                                                                                modules\which\which.js:80:29)
gyp verb `which` failed     at C:\Users\HP\Desktop\nodebook\projectname\node_mod                                                                                                                ules\which\which.js:89:16
gyp verb `which` failed     at C:\Users\HP\Desktop\nodebook\projectname\node_mod                                                                                                                ules\isexe\index.js:42:5
gyp verb `which` failed     at C:\Users\HP\Desktop\nodebook\projectname\node_mod                                                                                                                ules\isexe\windows.js:36:5
gyp verb `which` failed     at FSReqWrap.oncomplete (fs.js:152:21)
gyp verb `which` failed   stack: 'Error: not found: python2\n    at getNotFoundE                                                                                                                rror (C:\\Users\\HP\\Desktop\\nodebook\\projectname\\node_modules\\which\\which.                                                                                                                js:13:12)\n    at F (C:\\Users\\HP\\Desktop\\nodebook\\projectname\\node_modules                                                                                                                \\which\\which.js:68:19)\n    at E (C:\\Users\\HP\\Desktop\\nodebook\\projectnam                                                                                                                e\\node_modules\\which\\which.js:80:29)\n    at C:\\Users\\HP\\Desktop\\nodebook                                                                                                                \\projectname\\node_modules\\which\\which.js:89:16\n    at C:\\Users\\HP\\Deskto                                                                                                                p\\nodebook\\projectname\\node_modules\\isexe\\index.js:42:5\n    at C:\\Users\\                                                                                                                HP\\Desktop\\nodebook\\projectname\\node_modules\\isexe\\windows.js:36:5\n    at                                                                                                                 FSReqWrap.oncomplete (fs.js:152:21)',
gyp verb `which` failed   code: 'ENOENT' }
gyp verb check python checking for Python executable "python" in the PATH
gyp verb `which` succeeded python C:\Users\HP\AppData\Local\Programs\Python\Pyth                                                                                                                on36-32\python.EXE
gyp verb check python version `C:\Users\HP\AppData\Local\Programs\Python\Python3                                                                                                                6-32\python.EXE -c "import platform; print(platform.python_version());"` returne                                                                                                                d: "3.6.4\r\n"
gyp verb could not find "C:\Users\HP\AppData\Local\Programs\Python\Python36-32\p                                                                                                                ython.EXE". checking python launcher
gyp verb could not find "C:\Users\HP\AppData\Local\Programs\Python\Python36-32\p                                                                                                                ython.EXE". guessing location
gyp verb ensuring that file exists: C:\Python27\python.exe
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "C:\Users\HP\AppData\Local\Pr                                                                                                                ograms\Python\Python36-32\python.EXE", you can set the PYTHON env variable.
gyp ERR! stack     at PythonFinder.failNoPython (C:\Users\HP\Desktop\nodebook\pr                                                                                                                ojectname\node_modules\node-gyp\lib\configure.js:483:19)
gyp ERR! stack     at PythonFinder.<anonymous> (C:\Users\HP\Desktop\nodebook\pro                                                                                                                jectname\node_modules\node-gyp\lib\configure.js:508:16)
gyp ERR! stack     at C:\Users\HP\Desktop\nodebook\projectname\node_modules\grac                                                                                                                eful-fs\polyfills.js:284:29
gyp ERR! stack     at FSReqWrap.oncomplete (fs.js:152:21)
gyp ERR! System Windows_NT 10.0.16299
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\HP\\Desktop\\                                                                                                                nodebook\\projectname\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--ve                                                                                                                rbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_libr                                                                                                                ary="
gyp ERR! cwd C:\Users\HP\Desktop\nodebook\projectname\node_modules\node-sass
gyp ERR! node -v v8.9.4
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
Build failed with error code: 1
npm WARN [email protected] requires a peer of popper.js@^1.12.9 but none is instal                                                                                                                led. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\fse                                                                                                                vents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@                                                                                                                1.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"}                                                                                                                )

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] postinstall: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional log                                                                                                                ging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\HP\AppData\Roaming\npm-cache\_logs\2018-03-14T16_26_09_838                                                                                                                Z-debug.log

apiv1 directory

I am new to API this means API version 1 is used in this repo?

Indentation

Indentation is not consistent in all files. There are 2 column and 4 column indentation

nginx issue

I try to config api with nginx in aws . I got the following issue.

Nginx config

location /api/ {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
#try_files $uri$args $uri$args/ /index.html;

            proxy_pass http://127.0.0.1:3000;

    }

I stated app using PM2 .

Issue

http://34.208.10.117/api/products

Not Found

404

Error
at app.use (/usr/share/nginx/html/orderanythingapi/src/app.ts:59:13)
at Layer.handle [as handle_request] (/usr/share/nginx/html/orderanythingapi/node_modules/express/lib/router/layer.js:95:5)
at trim_prefix (/usr/share/nginx/html/orderanythingapi/node_modules/express/lib/router/index.js:312:13)
at /usr/share/nginx/html/orderanythingapi/node_modules/express/lib/router/index.js:280:7
at Function.process_params (/usr/share/nginx/html/orderanythingapi/node_modules/express/lib/router/index.js:330:12)
at next (/usr/share/nginx/html/orderanythingapi/node_modules/express/lib/router/index.js:271:10)
at /usr/share/nginx/html/orderanythingapi/node_modules/express/lib/router/index.js:618:15
at next (/usr/share/nginx/html/orderanythingapi/node_modules/express/lib/router/index.js:256:14)
at Function.handle (/usr/share/nginx/html/orderanythingapi/node_modules/express/lib/router/index.js:176:3)
at router (/usr/share/nginx/html/orderanythingapi/node_modules/express/lib/router/index.js:46:12)
at Layer.handle [as handle_request] (/usr/share/nginx/html/orderanythingapi/node_modules/express/lib/router/layer.js:95:5)
at trim_prefix (/usr/share/nginx/html/orderanythingapi/node_modules/express/lib/router/index.js:312:13)
at /usr/share/nginx/html/orderanythingapi/node_modules/express/lib/router/index.js:280:7
at Function.process_params (/usr/share/nginx/html/orderanythingapi/node_modules/express/lib/router/index.js:330:12)
at next (/usr/share/nginx/html/orderanythingapi/node_modules/express/lib/router/index.js:271:10)
at SendStream.error (/usr/share/nginx/html/orderanythingapi/node_modules/serve-static/index.js:121:7)

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.