Giter Site home page Giter Site logo

rethinkdb-express-api-boilerplate's Introduction

rethink-express-api-boilerplate

Another API boilerplate, based on express and rethinkdb backend.

my api would stay up

Includes:

  • Async/Promise methods into express (avoid next() callback hell)
  • Service generator with support for hooks and custom methods (see todo example)
  • Model generator (see todo example)
  • JWT-based Auth Service
  • Docker build image
  • User Service

Uses:

  • Express
  • RethinkDB
  • Babel latest preset (ES6, ES2015, ES2016, ES2017) + stage-0
  • cusspvz/node.docker

Requirements

  • Node.JS
  • Yarn / NPM
  • RethinkDB service

Instalation

git clone https://github.com/cusspvz/rethinkdb-express-api-boilerplate my-api
cd my-api
yarn install # or: npm install

Development

yarn run dev # or: npm run dev

Updating

Just place a new copy of the boilerplate/ folder on your project

for real?

And, of course, adjust dependencies on your package.json.

Building

npm run build

Docker image

Building

docker run build -t your-username/my-webapp .

Publishing

docker push your-username/my-webapp

rethinkdb-express-api-boilerplate's People

Contributors

cusspvz avatar franciscofsales 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

rethinkdb-express-api-boilerplate's Issues

How to add middlewares: [ parseToken ] to some routes and other not in same route space?

Simple:

export const Companies = new Service({
  model: Company,
  endpoint: '/companies',
  //middlewares: [ parseToken ],
  custom: {
    //need middleware here
    async 'POST /in-radius' (req) {
      
      let { body: { lon, lat, distance, measure } } = req
      const companies = await Company.getCompaniesInRadius(lon, lat, distance, measure)

      return {companies: companies}
    },
    //dont need middleware here
    async 'GET /:id' (req) {

      const { params: { id } } = req

      const company = await Company.get(id).getJoin({get_category: true}).run()

      return company

    },

  },

})

Not issue, upgrade maybe - one service for all models

Hi,

you got this index.js with bunch of services exported. But, logic is same for every of them. What i mean is this

service1.js - uses post/delete/patch/put
service2.js - uses post/delete/patch/put
service3.js - uses post/delete/patch/put

What i am thinking is to use one service for everything with endpoint taken from url model name.
So instead of having same number of services as number models, you just have one service.

What do you think? Is this doable?

problem with update query

I send to put to /url/:id

{
"some_key":"some_value"
}

and get this error:

ReqlDriverError: Unrecognized option some_key in update after:

Wrong password while connecting to db (can not be turth)

Hi,

I can not connect to remote or local db. I am getting error:

Entering slow growth mode
Fail to create a new connection for the connection pool. Error:{"msg":"Error 12:Wrong password","message":"Error 12:Wrong password.","isOperational":true}

I get bunch of that errors. I know username and password are correct since i have some python and go application that are using same username/password combination.

This is config:

export const thinky = Thinky({
  host: DB_HOST,
  port: DB_PORT,
  db: DB_NAME,
  user: DB_USER,
  pass: DB_PASS,
})

Bunch of errors on post ReferenceError: hook is not defined

So here it is for now:

  1. ReferenceError: hook is not defined when trying to do post at
    await hook( 'before create write', req, body )

  2. If i remove hook then i am getting model.create is not a function
    in here const obj = await model.create( body )

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.