• Stars
    star
    237
  • Rank 169,885 (Top 4 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created about 6 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Node REM - NodeJS Rest Express MongoDB and more: typescript, passport, JWT, socket.io, HTTPS, HTTP2, async/await, nodemailer, templates, pagination, docker, etc. Live Demo: https://node-rem-ngduc.vercel.app

Node REM

NodeJS Rest Express MongoDB (REM) - a production-ready lightweight backend setup.

Build Status Maintainability

Live Demo (login with a test user: [email protected], user111 - inspect API calls to learn more)

🌟 It rains cats and dogs features:

  Typescript      Express   CORS     Helmet    DotEnv   joi (validation)   forever
  Mongoose        Passport  JWT      Await
  Tslint          Apidoc    Docker   Husky    Morgan    Travis   Unix/Mac/Win (Powershell)
  Tests
            Mocha  Chai     Sinon    istanbul
  MORE:
            HTTPS           HTTP2 (spdy)      Socketio 2.1       Init DB Data
            Slack message   Nodemailer        Mailgun            Email Templates    Forgot Password
            VSCode Debug    Dependabot        Codacy             File upload (multer)
      API
            API response    (data, meta: limit, offset, sort)    Transform res
            apiJson         Pagination query
            Regex query     Whitelist fields in response         Populate deep fields
            mstime          API response time     Stack trace in Response
      UI Example
            CRA, Typescript, React-router, Axios, PostCSS, Tailwind. Components: Login, Home, ItemView.
            Portable-react

πŸ“¦ Installation

Require: MongoDB and NodeJS v8.12.0 +

Clone this project:

git clone https://github.com/ngduc/node-rem.git your-app
cd your-app
rm -rf .git   (remove this github repo's git settings)
yarn
  • Update package.json and .env file with your information.
  • Run yarn dev, it will create a new Mongo DB "node-rem"
  • Verify yarn test can run all unit tests.
  • Verify: use Postman to POST http://localhost:3009/api/v1/auth/register to create a new user. (set payload to have email, password)
curl -k -d '{"email": "[email protected]", "password": "testpsw"}' -H "Content-Type: application/json" -X POST http://localhost:3009/api/v1/auth/register

πŸ”§ Commands

- Start MongoDB first. Verify .env variables.

yarn dev      launch DEV mode
yarn start    launch PROD mode
yarn stop

yarn test     Run tests   (requires MongoDB)

Frontend Example - uses this node-rem backend:

- First, start the Backend with: yarn dev

- Then, start UI:
cd ./ui
yarn
yarn start    (then open http://localhost:3000 - login with a test user: [email protected], user111)

πŸ“– Features

Your simple API Route Handler will have a nice syntax like this: (packed with vitamins cool stuffs)

exports.list = async (req: Request, res: Response, next: NextFunction) => {
  try {
    const data = (await User.list(req)).transform(req); // query & run userSchema.transform() for response
    apiJson({ req, res, data, model: User }); // return standard API Response
  } catch (e) {
    next(e);
  }
};

API Response is similar to JSON API standard:

GET http://localhost:3009/api/v1/users?fields=id,email&email=*user1* (get id & email only in response)
GET http://localhost:3009/api/v1/users?page=1&perPage=20 (query & pagination)
GET http://localhost:3009/api/v1/users?limit=5&offset=0&sort=email:desc,createdAt
{
    "meta": {
        "limit": 5,
        "offset": 0,
        "sort": {
            "email": -1,
            "createdAt": 1
        },
        "totalCount": 4,
        "timer": 3.85,
        "timerAvg": 5.62
    },
    "data": [
        {
            "id": "5bad07cdc099dfbe49ef69d7",
            "name": "John Doe",
            "email": "[email protected]",
            "role": "user",
            "createdAt": "2018-09-27T16:39:41.498Z"
        },
        // more items...
    ]
}

Example of generated API Docs (using apidoc) - https://node-rem.netlify.com

πŸ“– Documentation

πŸ™Œ Thanks

All contributions are welcome!

UI Example uses Portable-react

More Repositories

1

react-tabulator

React Tabulator is based on tabulator - a JS table library with many advanced features.
CSS
357
star
2

react-setup

A Universal React Setup with i18n: Babel 6, Koa 2, React, React Router, React Transmit, React Bootstrap, React-intl, Mocha, Isparta, Webpack 2, Storybook, InlineCSS/PostCSS, ESLint, HTTPS & HTTP2.
JavaScript
175
star
3

life-calendar

Life Calendar: Your Life in Weeks
TypeScript
155
star
4

api-now

$ api-now - Launch an API Server to serve a JSON, JS file, GraphQL or faker data with HTTPS support.
JavaScript
108
star
5

vercel-express

Vercel Express and UI Webapp Example. Live Demo - https://vercel-express-ngduc.vercel.app/
TypeScript
67
star
6

Thin-PHP-Framework

A micro web framework - lightweight and flexible open source PHP5 MVC framework
PHP
41
star
7

parcelui

Parcel + Typescript + React/Preact + Router + CSS Modules + SASS + Jest + Api-Now + Github Actions CI
TypeScript
35
star
8

ui-form-field

ui-form-field based on formik - a simple way to work with Forms in React.
CSS
21
star
9

json-now

$ json-now - Launch an API Server to serve data from a JSON, JS file or faker data with HTTPS support. Based on json-server.
JavaScript
18
star
10

dashb

Dashb.io - Minimalist's Dashboard and Widgets.
HTML
12
star
11

flatten-sol

command-line tool to flatten a solidity contract which uses `import "@openzeppelin/contracts/...`.
JavaScript
11
star
12

mstime

a lightweight module (2KB gzip) to measure & visualize code performance in millisecond (ms), run on Node & browser. No dependencies!
JavaScript
11
star
13

portable-react

Simple React components written in Typescript using Tailwind CSS, all in one index.tsx file ~ 200 lines of code.
TypeScript
8
star
14

ez-react-form

A simple way to work with Forms in React.
CSS
8
star
15

rails-react-typescript-jest

Rails + React + Typescript + Jest UI app
Ruby
7
star
16

syntax-wiki

Source code for "syntax.wiki" website
HTML
7
star
17

create-blank-app

create-blank-app (cba) - just one command to remember - create a blank app.
JavaScript
6
star
18

dev-benchmark

Benchmark script to measure performance of usual development tools.
Shell
4
star
19

mystik

Mystik (MkTable) is a generic Javascript DAO (Data Access Objects) for database systems including NoSQL databases, Redis, NodeJS support and REST API web service handling.
JavaScript
3
star
20

react-18-ts-vite-app

React 18, Typescript, Vite and Vercel.
TypeScript
3
star
21

react-tabulator-examples

Created with CodeSandbox
JavaScript
3
star
22

framework-demos

FrameworkDemos.com is a place to show online web framework demos, online mobile framework demos, or library, UI control demos
JavaScript
2
star
23

better-pull-request

Better comment styles for Github Pull Request.
2
star
24

awesome-stellar

awesome resources about Stellar ecosystem
2
star
25

vercel-flask-ui

Vercel + Flask + UI
HTML
2
star
26

ez-formik

Easy-to-use components to use with formik - hence the name ez-formik.
CSS
2
star
27

crunchk.com

crunchk.com website
TypeScript
1
star
28

eth-fund

A site that lists campaigns or missions for fundraising, accepts any crypto tokens easily with transparency and NFT badges.
TypeScript
1
star
29

create-react-form

create-react-form - CRF
JavaScript
1
star
30

clean-up-action

Github Action to clean up resources.
JavaScript
1
star
31

px-elements

Polymer Elements, Web Components
HTML
1
star
32

px-test-utils

helper functions for mocha unit tests using teaspoon, react-addons-test-utils, etc.
JavaScript
1
star
33

forevercloud

Publish article, content using blockchain technology.
JavaScript
1
star
34

es5-html-elements

react-native-html-elements is a fork from @expo/html-elements but using "import * as" syntax.
TypeScript
1
star
35

px-login

React minimal reusable Login Component.
TypeScript
1
star
36

docker

Dockerfiles for lightweight dev/production images.
Dockerfile
1
star