Giter VIP home page Giter VIP logo

zuriportfolio-commander-backend's Introduction

Zuriportfolio - Backend

This is a Node.js / Express project bootstrapped with create-prospark-app.

Getting Started

First, run the development server:

npm run dev
# or
yarn dev
# or
pnpm dev

The following log message should be displayed in console output:

2023-04-17 23:14:38 PM [info] : Server started at http://localhost:8080

Visit http://localhost:8080/api/user/data in your browser just to confirm routes are configured and working properly. If all is working properly, you should get the below response on browser.

{
  "errorStatus": false,
  "code": "--user/fake-data",
  "message": "user data fetched successfully",
  "statusCode": 200,
  "data": [
    {
      "name": "john doe",
      "email": "[email protected]"
    },
    {
      "name": "brain tracy",
      "email": "[email protected]"
    }
  ]
}

Environmental Variable

Create a .env file inside the root of your application and include the following content:

DATABASE_URL='postgresql://postgres:@localhost:5432/prospark-db'

NODE_ENV="development"

JWT_SECRET="sdcsdcdc32ry38y9dpnp23i3892te832tp9e23on"

CLOUDINARY_NAME="ssdcsdcs"

CLOUDINARY_API_KEY="sdcscsdsdc"

CLOUDINARY_API_SECRET="sdcdscsdcc"

Navigate to cloudinary to retrieve needed info for your .env file.

Note!! you need to create the database zuriportfolio yourself before doing any other thing within the app if you need it to work properly. You could use tool like PhpMyAdmin or MysqlWorkBench

Droping all created tables

drop schema public cascade;
create schema public;

Routes

The routes can be found within the /routes directory. for eg the user route would handle routing that has to do with the user controllers which is prefix with /user/* and when been invoked, would be done in this format /api/user/*

const express = require('express');
const UserController = require('../controller/user');
const useCatchErrors = require('../error/catchErrors');

class UserRoute {
  router = express.Router();
  userController = new UserController();
  path = '/user';

  constructor() {
    this.initializeRoutes();
  }

  initializeRoutes() {
    this.router.get(`${this.path}/data`, useCatchErrors(this.userController.getUser.bind(this.userController)));
  }
}

module.exports = UserRoute;

Also, within each controller file, notice that try...catch isn't been used, this is because I've created an error method called useCatchErrors which would handle all exceptions / error thrown within any controller file.

Do Not Touch the Base file within the controller directory. It should only be inherited from.

Commit Standards

Branches

  • dev -> pr this branch for everything frontend & backend related
  • main -> dont touch this branch, this is what is running in production.

Contribution Guidelines

  1. Clone the repo git clone https://github.com/hngx-org/zuriportfolio-commander-backend.git.
  2. Open your terminal & set the origin branch: git remote add origin https://github.com/hngx-org/zuriportfolio-commander-backend.git
  3. Pull origin git pull origin dev
  4. Create a new branch for the task you were assigned to, eg : git checkout -b feat-csv-parser
  5. After making changes, do git add .
  6. Commit your changes with a descriptive commit message : git commit -m "your commit message".
  7. To make sure there are no conflicts, run git pull upstream dev.
  8. Push changes to your new branch, run git push -u origin feat-csv-parser.
  9. Create a pull request to the dev branch not main.
  10. Ensure to describe your pull request.
  11. If you've added code that should be tested, add some test examples.

Commit CheatSheet

Type Description
feat Features A new feature
fix Bug Fixes A bug fix
docs Documentation Documentation only changes
style Styles Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
refactor Code Refactoring A code change that neither fixes a bug nor adds a feature
perf Performance Improvements A code change that improves performance
test Tests Adding missing tests or correcting existing tests
build Builds Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
ci Continuous Integrations Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)
chore Chores Other changes that don't modify backend, frontend or test files
revert Reverts Reverts a previous commit

Sample Commit Messages

  • chore: Updated README file := chore is used because the commit didn't make any changes to the backend, frontend or test folders in any way.
  • feat: Added plugin info endpoints := feat is used here because the feature was non-existent before the commit.

zuriportfolio-commander-backend's People

Contributors

benrobo avatar edidiva avatar airzed avatar 150615 avatar cyrus-11 avatar extranodev avatar ceasar28 avatar thegodhope avatar benfaruna avatar iamstarcode avatar edahmitchel avatar ipiea avatar ezeibekweemma avatar excellencyjumo avatar oludayo02 avatar oludayo20 avatar aniebietafia avatar afomachinenye avatar chriss1525 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.