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 is a basic workflow to help you get started with Actions | |
name: CI-CD | |
# Controls when the action will run. | |
on: | |
# Triggers the workflow on push or pull request events but only for the main branch | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] |
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
FROM node | |
LABEL authors="Yann Mulonda" | |
# update dependencies and install curl | |
RUN apt-get update && apt-get install -y \ | |
curl \ | |
&& rm -rf /var/lib/apt/lists/* | |
# Create app directory | |
WORKDIR /app | |
# Install app dependencies | |
# A wildcard is used to ensure both package.json AND package-lock.json are copied |
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 will prevent your local modules and debug logs from being copied onto your | |
# Docker image and possibly overwriting modules installed within your image. | |
# ---------------------------------------------------------------------------------* | |
node_modules | |
npm-debug.log | |
# ignore .git and .cache folders | |
.git | |
.cache | |
# ignore all markdown files (md) beside all README*.md other than README-secret.md |
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
// **************************************************************** | |
// We're testing our app using JEST library | |
// Jest is a library for testing JavaScript code. It's an open | |
// source project maintained by Facebook. | |
// Jest is a way for having access to test runner and assertion | |
// library for NodeJS applications. | |
// **************************************************************** | |
describe("Testing our nodeJS app", () => { | |
it("Testing using Github Actions", () => { | |
// exoecting 3 functions and receiving 3 |
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
// ******************************************************************* | |
// "Routes" to forward the supported requests (and any information | |
// encoded in request URLs) to the appropriate controller functions. | |
// ******************************************************************* | |
// import my GET API from the controller functions | |
import { home, getTodayDate, getMonthsName,getIPeople } from '../controller/controller.js'; | |
// set up the routing | |
const routes = (app) => { | |
// home page | |
app.route('/') |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>nodeJS demo</title> | |
<style> | |
body {background-image: url('https://mdbootstrap.com/img/Photos/Others/images/77.jpg')} | |
h1,h2 {color: white; font-weight: bold;} | |
p {color: white;} | |
</style> | |
</head> |
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
// **************************************************************** | |
// Controller functions to get the requested data from the models, | |
// create an HTML page displaying the data, and return it to the | |
// user to view in the browser. | |
// **************************************************************** | |
import path from 'path'; | |
const __dirname = path.resolve(); | |
// show html page | |
export const home = (req, res) => { | |
//show this file when the "/" is requested |
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
// import Express and routes | |
import express from 'express'; | |
import routes from './source/routes/route.js'; | |
// constant variables | |
const app = express(); | |
const PORT = 3000; | |
const HOST = '0.0.0.0'; | |
// body parser setup for Express v4.16.0 and higher | |
app.use(express.json()); | |
app.use(express.urlencoded({ extended: true })); |
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
FROM node | |
# update dependencies and install curl | |
RUN apt-get update && apt-get install -y \ | |
curl \ | |
&& rm -rf /var/lib/apt/lists/* | |
# Create app directory | |
WORKDIR /app | |
# Install app dependencies | |
# A wildcard is used to ensure both package.json AND package-lock.json are copied | |
# where available (npm@5+) |
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
variables: | |
VERSION: v2 | |
MYNAME: Charlie | |
stages: | |
- npmtest | |
- sastscan | |
- dockerbuild | |
# test is the default Gitlad stage name when setting up SAST | |
- test | |
- runapp |