Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#17 Create the workflow CI. #21

Merged
38 changes: 38 additions & 0 deletions .github/workflows/workflow_for_ecomm.yml
niyibi250 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: CI for ecomm-project for Dynamite

on:
push:
branches: [ "develop" ]
pull_request:
branches: [ "develop" ]

jobs:
build:
#git hub offer virtual machines to run workflows so we will be using ubuntu lastest version its standand one
#we using ubuntu because we want to use lunex terminal
runs-on: ubuntu-latest

strategy:
matrix:
#each version we specify we be tested on
#we are only limited to 3 versions
node-version: [16.x, 18.x, 20.x]


steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }} #this will help use know which version we are testing on.
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm' #this we help speed up the workflow by reusing dependencies from previous runs
- run: npm ci #run dependencies installing we using ci in place of 'npm install' becouse ci(clearn install) is smooth and faster
- run: npm run test --if-present #this line will run test script
- run: npm run lint --if-present # run tle
- run: npm run build --if-present # we using if statement because initial the code have no build script in packege.json
- run: npm run test:ci --if-present # this will run test with coverage flag

- name: Upload coverage to Coveralls
uses: coverallsapp/github-action@v2
with:
allow-empty: true
4 changes: 2 additions & 2 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ app.get('/', (req: Request, res: Response) => {
});

// Middleware to handle all endpoint routes
app.use(process.env.ALL as string, route);
app.use('/api/v1', route);

// Endpoint for serving Swagger documentation
app.use(
process.env.DOCS as string,
'/api-docs',
swaggerUi.serve,
swaggerUi.setup(swaggerSpec)
);
Expand Down
8 changes: 7 additions & 1 deletion src/controller/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@ import {User} from '../database/models';

const userRepository = dbConnection.getRepository(User)

export const createUser = async(data:any) => {
interface UserData {
firstName: string;
lastName: string;
age: number;
}

export const createUser = async(data: UserData) => {
const user = new User()
user.firstName = data.firstName
user.lastName = data.lastName
Expand Down
2 changes: 1 addition & 1 deletion src/database/models/user.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Entity, PrimaryGeneratedColumn, Column } from "typeorm"
import { Entity, PrimaryGeneratedColumn, Column } from 'typeorm'

@Entity()
export class User {
Expand Down
Loading