Coder Social home page Coder Social logo

node_api_coding_convention's Introduction

node_api_coding_convention

Style Rule

Folder structure

project
|____migration/
|
|____config/
|    default.yml
|    custom-environment-variables.yml
|
|____node_mudules/
|
|____src/
|    |____app/
|    |    |____function/
|    |    |    |____sync/
|    |    |    |    *.sync.js
|    |    |    |    *.sync.test.js
|    |    |    |
|    |    |    |____aSync/
|    |    |    |    *.aSync.js
|    |    |    |    *.aSync.test.js
|    |    |    |
|    |    |    |____gRpc/
|    |    |    |    *.gRpc.js
|    |    |    |    *.gRpc.test.js
|    |    |    |
|    |    |____schemas/
|    |    |    *.schema.js
|    |    |    *.schema.test.js
|    |    |
|    |    |    errors.js
|    |    |    handler.js
|    |    |    router.js
|    |    
|    |____core/
|    |    *.core.js
|    |    *.core.test.js
|    |
|    |____protobuf/
|    |    *.proto
|    |
|    |____lib/
|    |    *.js
|    |    *.test.js
|    |
|    |____middlewares/
|    |    *.midd.js
|    |    *.midd.test.js
|    |
|    |____routes/
|    |    *.route.js
|    |    *.route.test.js
|    |
|    |____services/
|    |    *.service.js
|    |    *.service.test.js
|    |
|    |    app.js
|    |    app.test.js
|   .editorconfig
|   .eslintignore
|   .eslintrc.js
|   .gitignore
|   .prettierrc
|   .dockerignore
|   dockerfile
|   jest.config.js
|   package-lock.json
|   package.json
|   swagger.yaml

User Service:

  • Register by email: [POST] /api/users/register-by-email
  • Login: [POST] /api/users/login
// user.schema.js
const login = {
  type: "object",
  required: ["password"],
  additionalProperties: false,
  properties: {
    email: { type: "string", format: "email" },
    phoneNumber: { type: "string" },
    password: { type: "string" },
  },
};

const registerByEmail = {
  type: "object",
  additionalProperties: false,
  required: ["name", "password", "email"],
  properties: {
    name: { type: "string", minLength: 2 },
    email: { type: "string", format: "email" },
    password: { type: "string" },
  },
};

// user.routes.js
const validator = require("../middlewares/validator");
const schema = require("../app/schemas/user.schema");
const handler = require("../app/handler");

router.post("/users/login", validator(schema.login), handler.login);
router.post("/users/register_by_email", validator(schema.registerByEmail), handler.registerByEmail);

node_api_coding_convention's People

Contributors

dependabot[bot] avatar hoangthequyen96 avatar

Stargazers

 avatar

Watchers

 avatar  avatar

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.