Giter Site home page Giter Site logo

microservices-ticketing's Introduction

Ticketing App

Ticketing app following along with Microservices with Node and React

Development

  • Run skaffold dev to start the development K8s/Docker files

Routes*

  • We will use express-validator to validate input (req.body) as route middleware

    • validation: making sure the input is what we intend
    • sanitization: changing the input to what we need
    • Use validationResult to pull out the error messages produced during validation step
router.post(
  '/api/users/signup',
  [
    body('email').isEmail().withMessage('Email must be valid'),
    body('password').isString()
  ],
  (req, res) => {
    ...

Auth Routes

Route Method Body Purpose
/api/users/signup POST {email: string, password: string} Sign up for an account
/api/users/signin POST {email: string, password: string} Sign in to an existing account
/api/users/signout POST {} Sign out
/api/user/currentuser GET Return info about the user

* Tables generated with https://www.tablesgenerator.com/markdown_tables#

Notes

Error responses

  • As we include more microservices (possibly built using different frameworks/langauges), the error objects may also be formatted differently
  • We need to define the format of the error object returned to be consistent for the React front-end
  • Express error handling lets you create a custom middleware function for error handling; it must include 4 arguments in order to know that it is an error handling middleware
  • Using express-async-errors for throwing async errors
app.use(function (err, req, res, next) {
  console.error(err.stack);
  res.status(500).send('Something broke!');
});

Common error response for this project:

{
  errors: {
    message: string,
    field?: string
  }[]
}

Abstract Class

  • To ensure the error object/serializeError() method is consistent, we will use an abstract class (instead of Interface)
  • Cannot be initiated
  • Used to setup requirements for subclasses
  • Does create a class when translated to JS, which means we can check it as instanceOf (interfaces don't exist in JS)

SSL Error on dev

  • Ingress is setup to use https by default
  • To get around browser warning: type thisisunsafe in the Chrome privacy window

microservices-ticketing's People

Contributors

virtual 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.