Giter VIP home page Giter VIP logo

xdpmw-honganstore-core's Introduction

Server

Need to know before start !!!


- mysql
- wamp
- nodejs
- typescript
- eslint
- jwt


Node version

  • < 13 (ts-node can't run in node v13)

Prepare the dotenv

  • Create .env file in root folder
  • Copy the .env.sample code
  • Paste into .env

Run source:

  • npm install
  • Dev: npm run dev
  • Product: npm run build

File Structure

  • Api
    • Routes
      • _
      • Main.ts
    • Helper
      • jwt.helper.ts
    • Middleware
      • AuthMiddleware.ts
  • Config
    • Config.ts
  • index.ts
  • .env
  • .babelrc
  • .eslintrc.json
  • .gitignore
  • package.json
  • tsconfig.json

ENDPOINTS

  • Variant
    • GET
      • Có "/join/full" là api đó sẽ trả về full thông tin variant như tên size, tên color, tên cate, ...
      • /api/variant/?skip=...&limit=... => (Lấy variant theo phân trang)
      • /api/variant/single/:id => (Lấy 1 variant theo id của cloth)
      • /api/variant/all => (Lấy tất cả variant, chỉ có thể truy cập bằng admin) ===============================================
      • /api/variant/join/full/?skip=...&limit=... => (Lấy full thông tin variant theo phân trang)
      • /api/variant/join/full/all => (Lấy hết tất cả các variant full thông tin)
      • /api/variant/join/full/single/:id => (Lấy cụ thể 1 variant qua id của cloth)
      • /api/variant/join/full/cate/:id => (Lấy các variant thuộc category id) ===============================================
      • /api/variant/join/size-color/:id => (Lọc size và color có trong cloth đó qua cloth id) (nên gọi khi vào trang detail của sản phẩm)
  • Sign In
    • POST: /signin
  • Sign Up
    • POST: /signup
  • User
    • GET:
      • /api/user/?skip=...&limit=... => (Lấy user theo phân trang)
      • /api/user/all => (Lấy hết tất cả user, cần có quyền admin)
      • /api/user/single/:id => (Lấy cụ thể 1 user qua id, cần trùng id trong token với id trên params hoặc có quyền admin)
      • /api/user/info => (Lấy thông tin user qua token gửi lên header)
    • POST:
      • /api/user/add => (Thêm user, số lượng chỉ đc 1)
      • => Mẫu: { firstName: "...", lastName: "...", password: "...", email: "...", phone: "...", address: "..." }
    • PUT:
      • /api/user/update/:id => (Update thông tin user, không bao gồm password, số lượng 1 user trên 1 lần gửi, cần trùng id trong token với id trên params hoặc có quyền admin) (Có gửi password qua body thì cũng k update password)
      • => Mẫu: { firstName: "...", lastName: "...", email: "...", phone: "...", address: "..." }
      • /api/user/update-password/:id => (Update password user, số lượng 1 user trên 1 lần gửi, cần trùng id trong token với id trên params hoặc có quyền admin)
      • => Mẫu: { oldPassword: "...", newPassword: "..." }
    • DELETE:
      • /api/user/delete/:id (Xóa 1 user cụ thể qua id user, cần quyền admin)
      • /api/user/delete-multiple/:id (Xóa nhiều user qua ids đc gửi body, có thể chỉ gửi 1-n, không đc gửi 0, cần quyền admin) (Lưu ý: ids có "s")
      • => Mẫu: {ids: [1,2,3,4,5]}
  • Cloth
    • GET
      • /api/cloth/?skip=...?&limit=... => (Lấy cloth theo phân trang)
      • /api/cloth/single/:id => (Lấy cụ thể 1 cloth qua cloth id)
      • /api/cloth/all => (Lấy tất cả cloth, cần quyền admin)
      • /api/cloth/cate/:id => (Lấy cloth qua cate id)

Errors??

- Typesciprt or ts-node is not a external/internal command

===> npm install -g typescript ts-node

- Can't find DB_Host DB_Name ...

===> Look the Prepare the dotenv section

- ECONNREFUSED on 127.0.0.1:3306

===> Check process.env by console.log it to see if it have declare or not

===> If console not work, check the mysql's port in wamp, change into port 3306

xdpmw-honganstore-core's People

Contributors

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