Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@ jobs:

strategy:
matrix:
node-version: [12.x, 14.x, 16.x, 17.x, 18.x, 19.x]
node-version: [20.x, 22.x]

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm' # Added npm caching
- run: npm ci
- run: npm run build --if-present
- run: npm test --if-present
- run: npm test # Removed --if-present, tests should always run
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
node_modules
node_modules

# Vitest coverage directory
coverage/
32 changes: 0 additions & 32 deletions app.js

This file was deleted.

43 changes: 43 additions & 0 deletions dist/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const express_1 = __importDefault(require("express"));
const path_1 = __importDefault(require("path"));
const cookie_parser_1 = __importDefault(require("cookie-parser"));
const morgan_1 = __importDefault(require("morgan"));
const cors_1 = __importDefault(require("cors"));
const index_1 = __importDefault(require("./routes/index"));
const users_1 = __importDefault(require("./routes/users"));
const posts_1 = __importDefault(require("./routes/posts"));
const postwithuser_1 = __importDefault(require("./routes/postwithuser"));
const products_1 = __importDefault(require("./routes/products"));
const restaurants_1 = __importDefault(require("./routes/restaurants"));
const auth_1 = __importDefault(require("./routes/auth"));
const companies_1 = __importDefault(require("./routes/companies"));
const addresses_1 = __importDefault(require("./routes/addresses"));
const orders_1 = __importDefault(require("./routes/orders"));
const app = (0, express_1.default)();
app.use((0, morgan_1.default)('dev'));
app.use(express_1.default.json());
app.use(express_1.default.urlencoded({ extended: false }));
app.use((0, cookie_parser_1.default)());
app.use(express_1.default.static(path_1.default.join(__dirname, '..', 'public')));
app.use((0, cors_1.default)());
app.use('/', index_1.default);
app.use('/users', users_1.default);
app.use('/posts', posts_1.default);
app.use('/postwithuser', postwithuser_1.default);
app.use('/products', products_1.default);
app.use('/restaurants', restaurants_1.default);
app.use('/auth', auth_1.default);
app.use('/companies', companies_1.default);
app.use('/addresses', addresses_1.default);
app.use('/orders', orders_1.default);
// Error handling middleware (optional, but good practice)
app.use((err, req, res, next) => {
console.error(err.stack);
res.status(500).send('Something broke!');
});
exports.default = app;
84 changes: 84 additions & 0 deletions dist/bin/www.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#!/usr/bin/env node
"use strict";
/**
* Module dependencies.
*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const app_1 = __importDefault(require("../app")); // Will resolve to app.ts
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).

const debug_1 = __importDefault(require("debug"));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).

const http_1 = __importDefault(require("http"));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).

const debug = (0, debug_1.default)('mock-api:server');
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
Bad invocation.

/**
* Get port from environment and store in Express.
*/
const port = normalizePort(process.env.PORT || '3006');
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).

app_1.default.set('port', port);
/**
* Create HTTP server.
*/
const server = http_1.default.createServer(app_1.default);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).

/**
* Listen on provided port, on all network interfaces.
*/
server.listen(port);
server.on('error', onError);
server.on('listening', onListening);
/**
* Normalize a port into a number, string, or false.
*/
function normalizePort(val) {
const portNumber = parseInt(val, 10);
if (isNaN(portNumber)) {
// named pipe
return val;
}
if (portNumber >= 0) {
// port number
return portNumber;
}
return false;
}
/**
* Event listener for HTTP server "error" event.
*/
function onError(error) {
if (error.syscall !== 'listen') {
throw error;
}
const bind = typeof port === 'string'
? 'Pipe ' + port
: 'Port ' + port;
// handle specific listen errors with friendly messages
switch (error.code) {
case 'EACCES':
console.error(bind + ' requires elevated privileges');
process.exit(1);
break;
case 'EADDRINUSE':
console.error(bind + ' is already in use');
process.exit(1);
break;
default:
throw error;
}
}
/**
* Event listener for HTTP server "listening" event.
*/
function onListening() {
const addr = server.address();
let bind;
if (typeof addr === 'string') {
bind = 'pipe ' + addr;
}
else if (addr) {
bind = 'port ' + addr.port;
}
else {
bind = 'an unknown address'; // Should not happen in normal circumstances
}
debug('Listening on ' + bind);
}
151 changes: 151 additions & 0 deletions dist/database/addresses.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
[
{
"id": "fa94e061-5cfd-4712-8df5-7c7ada3599b5",
"street": "6928 E 1st Street",
"city": "Sugar Land",
"zipCode": "50990",
"country": "Belgium",
"userId": "4"
},
{
"id": "2f815f6e-6ed4-405b-87f1-ed8ffbfdff2c",
"street": "74021 West Avenue",
"city": "Baileycester",
"zipCode": "50210",
"country": "Guinea"
},
{
"id": "a701d0bc-a520-4275-a6a4-723c126709be",
"street": "2497 Manor Drive",
"city": "Juwanbury",
"zipCode": "96278-8054",
"country": "Fiji",
"userId": "1"
},
{
"id": "8ea3941a-2aa9-4380-b4e9-391ef24e2e05",
"street": "749 Grove Lane",
"city": "Greenfelderbury",
"zipCode": "26177-0813",
"country": "Gambia"
},
{
"id": "3feab1dd-7009-4888-a2a3-af2de3b9df09",
"street": "5218 Jefferson Street",
"city": "Quintonshire",
"zipCode": "82871",
"country": "Lithuania",
"userId": "1"
},
{
"id": "92ebb772-7f51-452e-8394-4ad2542896b5",
"street": "501 Fahey Street",
"city": "East Jermainmouth",
"zipCode": "16273-2342",
"country": "Togo"
},
{
"id": "8306a3b0-1b5d-42ed-b98f-b4648657cac7",
"street": "363 E Main Street",
"city": "West Randi",
"zipCode": "09860",
"country": "Northern Mariana Islands"
},
{
"id": "5ccad40d-24e1-4688-b049-a709d1fcef60",
"street": "29721 Water Lane",
"city": "East Joanie",
"zipCode": "31498-1740",
"country": "Australia"
},
{
"id": "da8999bd-c7ca-48d9-861e-265fcacec718",
"street": "859 Willms Vista",
"city": "Monroefort",
"zipCode": "47973-0287",
"country": "Lesotho"
},
{
"id": "d84ec28f-a53c-4129-9ba0-a913853bc41f",
"street": "807 Wolf Island",
"city": "North Salvatorechester",
"zipCode": "01345-2723",
"country": "Lebanon",
"userId": "2"
},
{
"id": "417c5a5c-a26d-4106-8d37-f8e706cb3d9a",
"street": "536 Kuhic Harbor",
"city": "Keeblerchester",
"zipCode": "78647",
"country": "Namibia",
"userId": "1"
},
{
"id": "e8ceda23-21db-4b39-ad96-09d10f4c26ed",
"street": "131 E Main",
"city": "Audreanneberg",
"zipCode": "69765",
"country": "Sweden"
},
{
"id": "70b947d9-60b0-4f49-a641-b3e07d9db702",
"street": "55695 Jerod Spring",
"city": "Mooremouth",
"zipCode": "32290",
"country": "Azerbaijan"
},
{
"id": "1381a987-966c-4679-a2bf-4798929c3610",
"street": "180 N Broadway",
"city": "Fort Ethyl",
"zipCode": "17089-0826",
"country": "Seychelles"
},
{
"id": "35abd1b2-91f5-4561-903e-a3efd5f8065c",
"street": "9967 Fay Landing",
"city": "Port Ednaside",
"zipCode": "84893-3585",
"country": "Luxembourg"
},
{
"id": "ee1f6507-5404-4e62-ac13-1b9f0675c996",
"street": "9799 Ebert Circle",
"city": "Katlynnberg",
"zipCode": "16995",
"country": "Fiji"
},
{
"id": "52c86a43-0afa-4e44-9011-ff132d51c32d",
"street": "99370 Ola Trace",
"city": "Melodystead",
"zipCode": "57916-5940",
"country": "North Macedonia",
"userId": "3"
},
{
"id": "23a3cb06-1ca0-4548-bc7a-95ae7f21a64c",
"street": "5286 Schneider Summit",
"city": "South Braulio",
"zipCode": "99944",
"country": "Panama",
"userId": "2"
},
{
"id": "a043d916-4eff-4d66-8810-61e09c2b31c0",
"street": "88796 Jessyca Field",
"city": "Farmington Hills",
"zipCode": "90269",
"country": "Vietnam",
"userId": "1"
},
{
"id": "0f244bb7-bcef-4c77-85dc-a550c4d064cb",
"street": "520 Amalia Glen",
"city": "South Abbeyborough",
"zipCode": "08120",
"country": "South Africa",
"userId": "1"
}
]
Loading