-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from TrackER-Corporation/Project-setup
chore: project setup
- Loading branch information
Showing
13 changed files
with
5,542 additions
and
147 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 } |
Oops, something went wrong.