10000 GitHub - AriaRahmati/shop-api: A simple Shop API
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

AriaRahmati/shop-api

Repository files navigation

Shop API

A simple Shop API

Table Of Contents

Tech Stack

  • Node.js - a JavaScript runtime environment for building and running server-side web applications
  • Express.js - a web application framework for Node.js
  • Mongodb - a NoSQL database
  • OpenAPI 3.0 - an API description format for REST APIs

Documentation

Documentation

Demo

Shop API hosted on Liara

Getting Started

Prerequisites

You need to install:

Upgrade npm to the latest version:

npm install npm@latest -g

Installation

Clone the repository and open project directory

git clone https://github.com/AriaRahmati/shop-api.git
cd shop-api

Install dependencies and run build command

npm install
npm run build

Create .env file

Environment Variables

To run this project, you will need to add the following environment variables to your .env file.

PORT = 'SERVER_PORT' # Default: 3000

DATABASE_URI = 'YOUR_MONGODB_URI'

JWT_SECRET = 'YOUR_JWT_SECRET'

JWT_LIFETIME = 'PREFERRED_JWT_LIFETIME' # Example: '60', '120ms', '2 days', '10h', '7d'

Run Locally

npm start
Development:
npm run dev

Console output should look like this:

connecting to database...
connected to database successfully
server is listening on port {PORT}

Then you can see the docs at http://localhost:{PORT}/api/v1/docs

and start working with the api at http://localhost:{PORT}/api/v1

Contributing

Based on commitlint documents:

Activate hooks

npx husky install

Add hook

npx husky add .husky/commit-msg  'npx --no -- commitlint --edit ${1}'

See Conventional Commits for more info.

Type Description
feat A new feature
fix A bug fix
docs Documentation only changes
style Changes that do not affect the meaning of the code (white-space, formatting etc)
refactor A code change that neither fixes a bug nor adds a feature
perf A code change that improves performance
test Adding missing tests or correcting existing tests
build Changes that affect the build system or external dependencies
ci Changes to our CI configuration files and scripts
chore Other changes that don't modify src or test files
revert Reverts a previous commit

Appendix

Shop API uses module-alias to make it easier to work with complex directory structures.

In order to make your intellisense to function, you need to add these paths to compilerOptions in jsconfig.json.

jsconfig.json
{
  "compilerOptions": {
    "baseUrl": "./",
    "module": "CommonJS",
    "target": "ESNext",
    "paths": {
      "@root/*": ["*"],
      "@src/*": ["src/*"],
      "@routes/*": ["src/routes/*"],
      "@configs/*": ["configs/*"],
      "@middlewares/*": ["src/http/middlewares/*"],
      "@controllers/*": ["src/http/controllers/*"],
      "@validators/*": ["src/http/validators/*"],
      "@models/*": ["src/models/*"],
      "@errors/*": ["src/errors/*"]
    }
  }
}

License

MIT

Authors

About

A simple Shop API

Resources

License

Stars

Watchers

Forks

Contributors 2

  •  
  •  
0