GithubHelp home page GithubHelp logo

restful-api-express's Introduction

Restful-API-Express

Xin chào, mình tên là Long (Longlee), mục đích mình tạo Repo này là muốn chia sẻ cách thực hiện và tạo ra 1 project chuẩn về Restful API. Thực tế đây là assignment của 1 bạn Inter nhờ mình thực hiện (hiện bạn ấy đang thực tập tại 1 công ty bên Mỹ), và mình nhận thấy assignment mà họ yêu cầu rất chặt chẽ và cực kỳ đầy đủ, đặc biệt là bộ test case. Chính vì vậy sau khi hoàn thành project này, mình muốn share với mọi người cách mà mình thực hiện , nếu có gì sai hoặc không chính xác, các bạn hãy comment vào các đoạn code hoặc đặt Issues cho mình nhé. Xin cảm ơn mọi người.

Hi, my name is Long (LongLee), I create this Repo because I want to share with you how to build and setup a Restul API project. In fact, this is an assignment from my friend (he is an Intern in USA), and I realized that this assignment is very complete, especially the test case. So, after I finished this project, I want to share to you what am I doing, if something is not correct, please comment into my code or you can create an Issues. Thanks.

Tổng quát

  • Setup 1 project với ExpressJS
  • Triển khai Restful API
  • Sử dụng Jest để test code
  • Tạo docs cho API sử dụng Swagger
  • Cấu hình cơ bản CORS

Cài đặt

Vào thư mục /api chạy lệnh sau

  • Linux

    npm install && npm install -g
    
  • Windows

      npm install; npm install -g
    

Dùng file dump.sql để tạo bảng và dữ liệu mặc định hoặc chạy lệnh: migrate để tạo các bảng cở sở dữ liệu (lưu ý lệnh migrate chỉ tạo bảng users)

Sau khi thực hiện xong truy cập vào http://localhost:3001 để kiểm tra.

Swagger

Truy cập vào đường dẫn http://localhost:3001/api-docs để đọc tài liệu về API.

Test

Vào thư mục /test và chạy lệnh npm install

Để thực hiện test API chạy lệnh sau

npm run test

restful-api-express's People

Contributors

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