GithubHelp home page GithubHelp logo

marketplace-api's Introduction

AD Marketplace API

Made by

About the project πŸ“‚:

Simple API for advertising and selling ads. Where you can post an ad or send a purchase intention by email. Made just for practice :)

Technologies πŸš€:

Technologies that I used to develop this API (used soft delete)

Directories tree

.
β”œβ”€β”€ src
β”‚   β”œβ”€β”€ config
β”‚   β”œβ”€β”€ controllers
β”‚   β”œβ”€β”€ database
β”‚   β”‚   └── migrations
β”‚   β”œβ”€β”€ dtos
β”‚   β”œβ”€β”€ errors
β”‚   β”œβ”€β”€ jobs
β”‚   β”œβ”€β”€ middlewares
β”‚   β”œβ”€β”€ models
β”‚   β”œβ”€β”€ repositories
β”‚   β”œβ”€β”€ routes
β”‚   β”œβ”€β”€ services
β”‚   β”œβ”€β”€ @types
β”‚   └── views
β”‚       └── emails
β”‚           β”œβ”€β”€ partials

Inside the project -

  • User: Represents a user, who can advertise and buy ads
  • Ad: Represents an ad, which can be purchased
  • Purchase: Represents a purchase intention a user has for a posted ad
  • Sale: Represents a sale, when a user accepts a purchase intention for one of your ads

Environment variables -

  • NODE_ENV: Defines the environment (Ex.: development / production)
  • PORT: Defines the port on which the application runs (Ex.: 3333)
  • APP_SECRET: Defines the secret of the application, which guarantees the uniqueness of the tokens (Ex.:asdybhq47qrdb)
  • APP_TTL: Defines the time of validity of a token (Ex.: 1d)
  • DB_TYPE: Defines the type of database (Ex.: postgres)
  • DB_HOST: Defines the host of database (Ex.: localhost)
  • DB_PORT: Defines the port of database (Ex.: 5432)
  • DB_USERNAME: Defines the username of database (Ex.: admin)
  • DB_PASSWORD: Defines the password of database (Ex.: admin123)
  • DB_NAME: Defines the name of database (Ex.: marketplace-api)
  • REDIS_HOST: Defines the host of redis (Ex.: 127.0.0.1)
  • REDIS_PORT: Defines the port of redis (Ex.: 6379)
  • MAIL_HOST: Defines the host of SMTP server (Ex.: smtp.mailtrap.io)
  • MAIL_PORT: Defines the port of SMTP server (Ex.: 2525)
  • MAIL_USERNAME: Defines the username of SMTP server (Ex.: a547ww)
  • MAIL_PASSWORD: Defines the password of SMTP server (Ex.: 5948wtgh)

Getting started πŸ–₯️:

Import the Insomnia.json on Insomnia App

Requirements

Obs.: I recommend use docker

Clone the project and access the folder

$ git clone https://github.com/adoidadox2/marketplace-api.git && cd marketplace-api

Follow the steps below

# Install the dependencies
$ yarn

# Make a copy of '.env.example' to '.env'
# and set with YOUR environment variables.
$ cp .env.example .env

# Create the instance of postgreSQL using docker
$ docker run --name marketplace-api-postgres -e POSTGRES_USER=docker \
              -e POSTGRES_DB=marketplace-api -e POSTGRES_PASSWORD=docker \
              -p 5432:5432 -d -t postgres

# Create the instance of Redis using docker
$ docker run --name marketplace-api-redis -p 6379:6379 -d -t redis:alpine

# Once the services are running, run the migrations
$ yarn typeorm migration:run

To start the server in a development environment:

$ yarn dev:server

To start the server in a production environment:

#To transpile from Typescript to Javascript
$ yarn build

#To run the server already transpiled
$ yarn start

Comments -

  • All ID's are uuid
  • Handled errors return their HTTP status and a specific error message. ** Ex ** .: {"status": "error", "message":" Ad not found "}
  • Unexpected errors are treated as status 500 - Internal Server Error

How to contribute πŸ€”:

Make a fork of this repository

# Fork using GitHub official command line
# If you don't have the GitHub CLI, use the web site to do that.

$ gh repo fork adoidadox2/marketplace-api

Follow the steps below

# Clone your fork
$ git clone your-fork-url && cd marketplace-api

# Create a branch with your feature
$ git checkout -b my-feature

# Make the commit with your changes
$ git commit -m 'feat: My new feature'

# Send the code to your remote branch
$ git push origin my-feature

After your pull request is merged, you can delete your branch

License πŸ“:

This project is licensed under the MIT License - see the LICENSE file for details.


Author πŸ‘¨β€πŸ’»:

Made with ❀️ by Augusto VinΓ­cius πŸ‘‹πŸ» Get in touch!

marketplace-api's People

Contributors

adoidadox2 avatar

Stargazers

 avatar Marcelo Lima avatar

Watchers

James Cloos 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.