Skip to content

Commit

Permalink
Add Package source code
Browse files Browse the repository at this point in the history
  • Loading branch information
bryantson committed May 25, 2022
1 parent 6311fc2 commit 49ebc9b
Show file tree
Hide file tree
Showing 8 changed files with 251 additions and 0 deletions.
116 changes: 116 additions & 0 deletions nodejs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
# 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
*.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

# 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 variables file
.env
.env.test

# 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

# 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.*
11 changes: 11 additions & 0 deletions nodejs/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM ghcr.io/bryantsonfabrikam/node:latest

WORKDIR /app

COPY ["package.json","package-lock.json*","./"]

RUN npm install

COPY . .

CMD ["npm","start"]
27 changes: 27 additions & 0 deletions nodejs/__tests__/filterByTerm.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const filterByTerm = require("../function.js");

describe("Filter function", () => {
test("Test 1", () => {
const input = [
{id: "1", url: "http://www.google.com" },
{id: "2", url: "http://www.msn.com" },
{id: "3", url: "http://www.test.com"}
];

const output = [ { id: "3", url: "http://www.test.com" }];

expect(filterByTerm(input, "test")).toEqual(output);
});

test("Test 2", () => {
const input = [
{id: "1", url: "http://www.google.com" },
{id: "2", url: "http://www.msn.com" },
{id: "3", url: "http://www.test.com"}
];

const output = [ { id: "2", url: "http://www.msn.com" }];

expect(filterByTerm(input, "msn")).toEqual(output);
});
});
7 changes: 7 additions & 0 deletions nodejs/function.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
function filterByTerm(inputArr, searchTerm) {
return inputArr.filter(function(arrayElement){
return arrayElement.url.match(searchTerm);
});
}

module.exports = filterByTerm;
15 changes: 15 additions & 0 deletions nodejs/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "nodejs-app",
"scripts": {
"test": "jest --coverage --json --outputFile=./output.txt",
"start": "node server.js"
},
"dependencies": {
"jest": "~27.0.5",
"express": "~4.17.1"
},
"jest": {
"collectCoverage": true,
"coverageReporters": ["html"]
}
}
Binary file added nodejs/public/hula_octocat.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
61 changes: 61 additions & 0 deletions nodejs/public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<html>
<head>
<title>Hello, GitHub Universe 2021</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x" crossorigin="anonymous">

</head>
<body>
<div class="container">
<nav class="navbar navbar-light bg-light">
<div class="container-fluid">
<a class="navbar-brand">Navbar</a>
<form class="d-flex">
<input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
<button class="btn btn-outline-success" type="submit">Search</button>
</form>
</div>
</nav>

<h1>Hello, GitHub Universe 2021. Mona the Octocat welcomes you!</h1>

<h3>You have successfully built your NodeJS application through GitHub Actions!</h3>

<img src="hula_octocat.gif" width="50%" height="50%" />

These are some possible GitHub Packages

<table class="table table-striped">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Package Type</th>
<th scope="col">URL</th>
<th scope="col">Documentation</th>
</tr>
<tbody>
<tr>
<th scope="row">1</th>
<td>Container Registry</td>
<td>ghrc.io</td>
<td><a href="https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry">Documentation to Container Registry</a></td>
</tr>
<tr>
<th scope="row">2</th>
<td>NPM Registry</td>
<td>https://npm.pkg.github.com</td>
<td><a href="https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-npm-registry">Documentation to NPM Registry</a></td>
</tr>
<tr>
<th scope="row">3</th>
<td>Ruby Gems Registry</td>
<td>https://rubygems.pkg.github.com</td>
<td><a href="https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-rubygems-registry">Documentation to Ruby Gem Registry</a></td>

</tr>

</tbody>
</table>

</div>
</body>
</head>
14 changes: 14 additions & 0 deletions nodejs/server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const express = require("express");
const app = express();

app.use(express.static("public"));

app.get("/", (req, res) => {
res.send("Hello, World");
});

const server = require("http").createServer({},app);

server.listen(80, function() {
console.log("HTTPS listening on port 80");
});

0 comments on commit 49ebc9b

Please sign in to comment.