Skip to content

Commit

Permalink
Merge pull request #3 from TrackER-Corporation/Project-setup
Browse files Browse the repository at this point in the history
chore: project setup
  • Loading branch information
LeleDallas authored Apr 24, 2023
2 parents 82be053 + dd62d48 commit 2e50b65
Show file tree
Hide file tree
Showing 13 changed files with 5,542 additions and 147 deletions.
94 changes: 67 additions & 27 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,76 @@
# This is a basic workflow to help you get started with Actions

name: CI

# Controls when the workflow will run
name: Build
permissions:
contents: write
pull-requests: write
on:
# Triggers the workflow on push or pull request events but only for the "main" branch
push:
branches: [ "main" ]
branches:
- main
pull_request:
branches: [ "main" ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
types: [opened, synchronize, reopened]
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
sonarcloud:
name: SonarCloud
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
with:
node-version: "18"
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
- name: Run tests & coverage
run: |
npm ci
npm run test
npm run coverage
env:
CI: true
- name: Vitest Coverage Report
uses: davelosert/[email protected]
with:
vite-config-path: './vite.config.ts'

# Runs a single command using the runners shell
- name: Run a one-line script
run: echo Hello, world!
docker:
name: Docker
runs-on: ubuntu-latest
needs: sonarcloud
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Set up QEMU
uses: docker/setup-qemu-action@v2
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
-
name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Build and push
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: leledallas/tracker-server:activity

# Runs a set of commands using the runners shell
- name: Run a multi-line script
run: |
echo Add other actions to build,
echo test, and deploy your project.
release-please:
name: Release Please
needs: docker
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Release Please Action
uses: google-github-actions/release-please-action@v3
with:
node-version: "18"
release-type: node
package-name: release-please-action
135 changes: 15 additions & 120 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,127 +4,22 @@ logs
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
.pnpm-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
node_modules
dist
dist-ssr
*.local
coverage
*.lcov

# 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/

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional stylelint cache
.stylelintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variable files
# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
*.DS_Store
.env
.env.development.local
.env.test.local
.env.production.local
.env.local

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

# Next.js build output
.next
out

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# vuepress v2.x temp and cache directory
.temp
.cache

# Docusaurus cache and generated files
.docusaurus

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
20 changes: 20 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Use an official Node runtime as a parent image
FROM node:18.5.0-alpine

# Set the working directory to /app
WORKDIR /app

# Copy the package.json and package-lock.json files to the container
COPY package*.json ./

# Install dependencies
RUN npm install

# Copy the rest of the application files to the container
COPY . .

# Expose port 3001 for the application to run on
EXPOSE 3006

# Start the application
CMD ["npm", "run", "dev"]
24 changes: 24 additions & 0 deletions db/services/database.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import * as mongoDB from "mongodb";
import * as dotenv from "dotenv";

export const collections: { cards?: mongoDB.Collection } = {}

export async function connectToDatabase() {
dotenv.config();

try {
const client: mongoDB.MongoClient = new mongoDB.MongoClient(process.env.DB_CONN_STRING!);

await client.connect();

const db: mongoDB.Db = client.db(process.env.DB_NAME);

const cardsCollection: mongoDB.Collection = db.collection(process.env.CARDS_COLLECTION_NAME!);

collections.cards = cardsCollection;

console.log(`Successfully connected to database: ${db.databaseName} and collection: ${cardsCollection.collectionName}`);
} catch (error) {
console.error(error);
}
}
23 changes: 23 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import express from 'express';
import dotenv from 'dotenv';
import cors from 'cors';
import { connectToDatabase } from './db/services/database.service';

dotenv.config();

const port = process.env.PORT;

const app = express();
app.use(cors());
app.use(express.json());

app.use(
'/',
(req, res, next) => {
return res.status(200).json({ "msg": "test" })
});

connectToDatabase()
app.listen(port, () => console.info(`tracker-activity-service is running`));

export default { app }
Loading

0 comments on commit 2e50b65

Please sign in to comment.