Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
karanikiotis authored Oct 8, 2024
0 parents commit 927357e
Show file tree
Hide file tree
Showing 34 changed files with 16,572 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
root = true

[*]
indent_style = tab
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.{yaml,yml}]
indent_style = space
indent_size = 2
15 changes: 15 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
CLIENT_URL=

SENTRY_DSN=
SENTRY_ENVIRONMENT=

SENDGRID_API_KEY=
SENDGRID_EMAIL=

SERVER_SECRET=

DATABASE_URL=

GOOGLE_CLIENT_ID=

PORT=
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto eol=lf
41 changes: 41 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: ci

on: push

jobs:
ci:
runs-on: ubuntu-latest
env:
PORT: 3000
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v2

- name: ⎔ Setup node
uses: actions/setup-node@v2
with:
node-version: "16.14.0"
cache: npm

- name: 📥 Download deps
run: npm i --legacy-peer-deps

- name: 🧪 Run test script
run: npm test
deploy:
if: ${{ false }} # disable for now
needs: ci
runs-on: ubuntu-latest
steps:
- uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_KEY }}
port: ${{ secrets.SSH_PORT }}
script: |
cd ~/template-backend
git reset --hard origin/main
git pull https://${{ secrets.CLONE_TOKEN }}@github.com/robotics-4-all/template-backend main
bash -ci 'npm i --legacy-peer-deps'
bash -ci 'pm2 restart server'
70 changes: 70 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache

.npmrc

src/assets/uploads/*
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
16
27 changes: 27 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
FROM node:16

WORKDIR /usr/src/app

# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available (npm@5+)
COPY package*.json ./

RUN npm install

# Bundle app source
COPY . .

ENV CLIENT_URL ""
ENV SENTRY_DSN ""
ENV SENTRY_ENVIRONMENT ""
ENV SENDGRID_API_KEY ""
ENV SENDGRID_EMAIL ""
ENV SERVER_SECRET ""
ENV DATABASE_URL ""
ENV GOOGLE_CLIENT_ID ""
ENV PORT 4000

EXPOSE 8081

CMD ["npm", "start"]
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
This is a template backend.

## Prerequisites

- node >=16

## Install

```sh
$ npm i
```

## Usage

```sh
$ npm start
```

## Run tests

```sh
$ npm test
```

## Development

```sh
$ npm run dev
```
9 changes: 9 additions & 0 deletions build_image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

TAG="template/template-back:latest"

if [[ $1 != "" ]]; then
TAG=$1
fi

docker build --tag ${TAG} .
13 changes: 13 additions & 0 deletions ecosystem.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = {
apps: [
{
name: "server",
script: "npm",
args: "start",
env: {
NODE_ENV: "production",
PORT: 4000,
},
},
],
};
Loading

0 comments on commit 927357e

Please sign in to comment.