Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
cd9051d
initiate a project structure
hallydon Jan 19, 2023
568007d
Merge pull request #2 from hallydon/feat/project
inidaname Jan 19, 2023
3532098
Merge pull request #4 from mainheartng/dev
inidaname Jan 22, 2023
a650b9b
project directory structure
hallydon Jan 23, 2023
f5981f9
Merge pull request #8 from hallydon/feat/project
hallydon Jan 23, 2023
d123328
Merge pull request #9 from mainheartng/dev
inidaname Jan 24, 2023
5b3c124
feat: added little description for the readme
inidaname Jan 24, 2023
dbdd788
API dependencies
hallydon Jan 24, 2023
3d018e9
Merge pull request #12 from inidaname/feat/updating-readme-description
inidaname Jan 24, 2023
668f6ca
Other dependencies
hallydon Jan 24, 2023
095912d
Merge pull request #13 from hallydon/feat/project
inidaname Jan 24, 2023
5fdd9eb
feat: add and configure husky for git linting
inidaname Jan 30, 2023
2c540f3
feat: add npm script
hallydon Jan 31, 2023
712218d
feat/#6 create entry point
hallydon Jan 31, 2023
70c0ba5
Merge pull request #18 from hallydon/14-feat-add-npm-script
inidaname Jan 31, 2023
4c8f197
Merge pull request #17 from inidaname/feat/15-Add-and-configure-husky…
inidaname Jan 31, 2023
512116c
Merge pull request #19 from hallydon/feat/6-creat-entry-point
inidaname Jan 31, 2023
2870cd8
fix: 24 node not reaching the end of the file
hallydon Feb 1, 2023
53d439b
feat: add a return object to index
hallydon Feb 1, 2023
cc32b60
Merge pull request #25 from hallydon/feat/20-add-a-return-object-to-i…
inidaname Feb 1, 2023
0be65d3
feat: 16 add and configure eslint
hallydon Feb 2, 2023
774953e
Merge pull request #29 from hallydon/feat/16-add-and-configure-eslint
inidaname Feb 3, 2023
81802f4
Merge pull request #21 from mainheartng/dev
inidaname Feb 3, 2023
ebd7ec9
feat: implemented github action for linux deployment
inidaname Feb 7, 2023
aa954e0
Update staging-deploy.yml
inidaname Feb 7, 2023
b1f1909
Merge pull request #34 from mainheartng/feat/33-implement-github-actions
inidaname Feb 7, 2023
9c05ffd
feat: implement github actions
inidaname Feb 11, 2023
2dcc399
Merge pull request #38 from inidaname/feat/33-implement-github-actions
inidaname Feb 11, 2023
d716c00
feat: eliminating linting till implemented
inidaname Feb 11, 2023
aa72e1d
feat: eliminating linting till implemented
inidaname Feb 11, 2023
fa5f4ab
feat: eliminating linting till implemented
inidaname Feb 11, 2023
ea84584
Merge pull request #39 from inidaname/feat/33-implement-github-actions
inidaname Feb 11, 2023
37b023e
feat: seprated deployement pipeline config
inidaname Feb 11, 2023
11cde04
bug: merge conflict
inidaname Feb 11, 2023
cee4024
Merge pull request #40 from inidaname/feat/33-implement-github-actions
inidaname Feb 11, 2023
18e9bb5
Merge pull request #41 from mainheartng/dev
inidaname Feb 11, 2023
2518f39
feat: add seprate config for staging
inidaname Feb 11, 2023
ce9642e
Merge pull request #42 from inidaname/feat/33-implement-github-actions
inidaname Feb 11, 2023
5ef6a43
Merge pull request #43 from mainheartng/dev
inidaname Feb 11, 2023
ae22181
feat: edit config to deploy properly
inidaname Feb 11, 2023
6552ca7
Merge pull request #44 from inidaname/feat/33-implement-github-actions
inidaname Feb 11, 2023
3ea8516
Merge pull request #45 from mainheartng/dev
inidaname Feb 11, 2023
afa8af6
feat: added bot to notify build pipeline on slack
inidaname Feb 11, 2023
7bcc617
feat: editing env
inidaname Feb 11, 2023
e9f1a23
feat: editing env
inidaname Feb 11, 2023
7757721
feat: still to get this to work
inidaname Feb 11, 2023
d0c2555
feat: still to get this to work
inidaname Feb 11, 2023
b564379
feat: still to get this to work
inidaname Feb 11, 2023
97f098f
Merge pull request #46 from inidaname/feat/33-implement-github-actions
inidaname Feb 11, 2023
0558e51
db migration
keemzyddev Feb 12, 2023
f7c6ed2
removed babelrc
keemzyddev Feb 13, 2023
706306f
removed babelrc and the comments in some files
keemzyddev Feb 13, 2023
c47f591
feat: removed dev script and babel pakages
keemzyddev Feb 13, 2023
8eb7273
feat: removed dev script and babel pakages
keemzyddev Feb 13, 2023
a424c13
feat: removed dev script and babel pakages
keemzyddev Feb 13, 2023
714a43f
fix: removed dev script and babel pakages
keemzyddev Feb 13, 2023
145b57a
fix: removed dev script and babel pakages
keemzyddev Feb 13, 2023
bbb256a
fix: removed dev script and babel pakages
keemzyddev Feb 13, 2023
1448689
Merge pull request #47 from keemzyddev/feat/123-db-migration
inidaname Feb 13, 2023
c5b273d
fix: Chenge Entery point
hallydon Feb 15, 2023
733b8ae
feat: Implement api version
hallydon Feb 15, 2023
eab2001
feat: Implement middlewares
hallydon Feb 15, 2023
86f6339
Merge pull request #50 from hallydon/feat/36-implement-api-v0
inidaname Feb 15, 2023
a60c8f9
Merge pull request #51 from mainheartng/dev
inidaname Feb 16, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added .circleci/config.yml
Empty file.
12 changes: 12 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module.exports = {
env: {
browser: false,
es2021: true,
},
extends: "eslint:recommended",

parserOptions: {
ecmaVersion: "latest",
sourceType: "module",
},
};
32 changes: 32 additions & 0 deletions .github/workflows/check-and.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: CodeCheck
run-name: GitHub is checking ${{ github.actor }} code

on:
pull_request:
types:
- opened
- reopened
- edited
- synchronize
branches:
- dev

jobs:
lint-pr:
name: Lint pull request title
runs-on: ubuntu-latest
steps:
- name: Lint pull request title
uses: jef/conventional-commits-pr-action@v1
with:
token: ${{ secrets.CO_ACCESS }}

project-prepare:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: lint-code
uses: actions/setup-node@v3.6.0
- run: npm install
# - run: npm run lint
80 changes: 80 additions & 0 deletions .github/workflows/staging-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: staging-deploy
run-name: Code deploying to staging env

on:
push:
branches:
- "staging"

jobs:
deploy-staging:
name: Deploy staging code
runs-on: ubuntu-latest
steps:
- name: Notify slack success
if: success()
id: slack # IMPORTANT: reference this step ID value in future Slack steps
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
uses: voxmedia/github-action-slack-notify-build@v1
with:
channel: build-notify
status: STARTING
color: warning

- name: Installing Start
uses: actions/checkout@v2
- uses: actions/setup-node@v1

- run: npm install

- name: Install SSH Key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SERVER_SSH }}
known_hosts: unnecessary
if_key_exists: ignore

- name: Adding Known Hosts
run: ssh-keyscan -p ${{ secrets.SSH_PORT}} -H ${{ secrets.SERVER_IP }} >> ~/.ssh/known_hosts

- name: Deploy with rsync
run: rsync -avz -e "ssh -p ${{ secrets.SSH_PORT }}" . ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_IP }}:/var/www/backendapi/

- name: Restart Node Server
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USER }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
port: ${{ secrets.SSH_PORT }}
script: |
cd /var/www/zellwk.com
git fetch origin master
git reset --hard FETCH_HEAD
git clean -d -f --exclude secrets
npm install --production
chown $(whoami) . # PM2 doesn't recognize root user from Github Actions
npm start

- name: Notify slack success
if: success()
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
uses: voxmedia/github-action-slack-notify-build@v1
with:
# Updates existing message from the first step
message_id: ${{ steps.slack.outputs.message_id }}
channel: build-notify
status: SUCCESS
color: good

- name: Notify slack fail
if: failure()
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
uses: voxmedia/github-action-slack-notify-build@v1
with:
channel: build-notify
status: FAILED
color: danger
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
.env
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx --no -- commitlint --edit ${1}
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"yaml.schemas": {
"file:///Users/hassansani/.vscode/extensions/atlassian.atlascode-3.0.1/resources/schemas/pipelines-schema.json": "bitbucket-pipelines.yml",
"https://json.schemastore.org/github-workflow.json": "file:///Users/hassansani/Documents/MainHeart/backend-api/.github/workflows/check-and.yml"
}
}
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
# backend-api
# MainHeart API application
This is the backend of the application the team is working on if you want to know tools and resources used in building the API, including decision made as we move. Please check the repo [mainheartng/organization/tools](https://github.com/mainheartng/organization/blob/main/Tools%20and%20Resources%20for%20the%20project.md#description)
45 changes: 45 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import express from "express";
import cors from "cors";
// import "./src/models/index.js";
import logger from "morgan";
import helmet from "helmet";

const port = 3000;

const app = express();

app.use(cors());

app.use(function(req, res, next){
res.header("Access-Control-Allow-Origin", "*");
res.header(
"Access-Control-Allow-Headers",
"Origin, X-Requested-With, Content-Type, Accept, Authorization"
);
res.header("X-Powered-By", "Mainheart and co.")
if(req.method === 'OPTIONS'){
res.header("Access-Control-Allow-Methods","POST, PUT, GET, DELETE, PATCH");
return res.status(200).json({});
}
next()
})

app.use(logger("dev"))

app.use(express.json())

app.use(express.urlencoded())

app.use(helmet())


app.get("/", function (req, res) {
res.json({
status: 200,
message: "Welcome to Main Heart Api",
});
});

app.listen(port, function () {
return console.log("Running on 3000");
});
7 changes: 7 additions & 0 deletions commitlint.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
extends: ['@commitlint/config-conventional'],
rules: {
'type-enum': [2, 'always', ['feat','feat-req', 'feat-request', 'bug', 'meeting', 'discussion', 'management']],
},
helpUrl: "https://github.com/mainheartng/organization/blob/main/gitflow-general.md"
};
Loading