Giter VIP home page Giter VIP logo

catalog-api's Introduction

Service Catalog

A simple dockerized service catalog restful backend using NestJs, TypeORM, TypeScript and PostgreSQL

Features

  • user management and JWT auth;
  • service catalog CRUD function, supporting filtering, sorting, searching and pagination;
  • fine-graded permission / access control;
  • healthcheck endpoint and OpenAPI swagger doc;

Running the app

docker-compose up -d
  • the catalog application is exposed on localhost port 3000;
  • sign up via /auth/signup using admin as the username to be the admin; any other usernames will be normal users; - get the access token via /auth/signin;
  • add the Authorization with the access token header to each request to further explore the application;
  • all the credentials can be found here .env

API endpoints

for more information, please check catalog-api doc

Endpoint Description
http://localhost:3000/doc api swagger doc
http://localhost:3000 healthcheck
http://localhost:3000/auth/signup user sign up
http://localhost:3000/auth/signin user sign in
http://localhost:3000/service POST to add a service
http://localhost:3000/service/:id GET a service
http://localhost:3000/service/:id DELETE a service
http://localhost:3000/service/:id UPDATE a service
http://localhost:3000/service/ GET a list of services, supporting basic pagination
http://localhost:3000/service/search search a list of services, supporting filtering, sorting, pagination
http://localhost:3000/permission/grant grant a user to access a service
http://localhost:3000/permission/remove remove a user from accessing a service
http://localhost:3000/permission GET a list of services that allows to be accessed for the current user
http://localhost:3000/permission/:id GET a list of services that allows to be accessed for the given user

Design

The service catalog api was designed for small- and medium-sized enterprises.

Function design

It contains 3 major features/functions:

  • auth: user management
  • permission: fine-graded permission management
  • service: service catalog management

Architectural design

Constricted by time, all the above 3 functions are built into one application and dockerized together with postgres database.

Another possible architectural design for large enterprises

For large enterprises, the above 3 features/functions can be optionally separated into 3 applications with their own persistent layers.

another possible design

Authentication/Authorization

there few layers of access control

For the service catalog endpoints, there few layers of access control:

  • all the endpoint requires JWT auth;

  • admin users have the full access to the all the services;

  • for normal users, the fine-graded permission (the permission endpoint) plays a role here.

    1. all the users can have the full access to the services added by themselves;
    2. services created a different users can only be accessed after the permission being granted by admin users;
    3. When retrieving a list of services, only permitted services are exposed.
    4. The fine-graded permission is implemented by NestJS interceptors;

Additional considerations

  • This is a weekend POC project and the author has never been previously exposed to NestJS. Reading NextJS documentation and coding happened within a very short period and there are tons of points to be improved for production purpose;
  • The project needs more tests (need more time) and ideally, a pipeline should be included/setup for CI/CD;

catalog-api's People

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.