Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion .azure/azure-pipelines.push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ extends:
steps:
- template: /templates/test/npm.yml@stratus-templates
parameters:
nodeVersion: 18
nodeVersion: 24
4 changes: 2 additions & 2 deletions .azure/azure-pipelines.release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ extends:
steps:
- template: /templates/test/npm.yml@stratus-templates
parameters:
nodeVersion: 18
nodeVersion: 24

- stage: release
displayName: Release
Expand All @@ -60,7 +60,7 @@ extends:
steps:
- template: /templates/npm/publish.yml@stratus-templates
parameters:
nodeVersion: 18
nodeVersion: 24
version: ${{ parameters.version }}
dryRun: ${{ parameters.dryRun }}
pushTags: ${{ parameters.pushTags }}
4 changes: 0 additions & 4 deletions .eslintrc

This file was deleted.

7 changes: 0 additions & 7 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,3 @@ updates:
labels:
- dependencies
- dependabot
ignore:
- dependency-name: 'eslint'
versions: ['9.x']
- dependency-name: 'node-fetch'
versions: ['3.x']
- dependency-name: 'express'
versions: ['5']
2 changes: 1 addition & 1 deletion .gitleaksignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# False positive git leaks
# The path /home/vsts/work/1/github/ is the root path of the pipeline agent

/home/vsts/work/1/github/test/certs/withpassphrase.pfx:pkcs12-file:1
/home/vsts/work/1/github/test/certs/withpassphrase.pfx:pkcs12-file:0
5 changes: 1 addition & 4 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

./node_modules/.bin/pretty-quick --staged
npx lint-staged
3 changes: 0 additions & 3 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npm run test
2 changes: 2 additions & 0 deletions .lintstagedrc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
'*.{js,jsx,ts,tsx}': prettier --write
'*.{yml,yaml,json,md}': prettier --list-different
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@

All notable changes for major version updates will be documented here.

## 5.0.0

### Breaking changes

- Requires Node.js `>=24`.
- Upgraded runtime dependency `express` from v4 to v5.

### Notable changes

- Updated tooling stack to modern versions (ESLint 9, Jest 30, Husky 9).
- Migrated linting configuration to flat config (`eslint.config.js`) and removed legacy `.eslintrc`.
- Removed `node-fetch` from development dependencies and aligned tests with native Node capabilities.
- Updated project docs and license metadata.

## 4.0.0

The package has been renamed to @kth/server.
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
The MIT License (MIT)
Copyright (c) 2016 KTH Royal Institute of Technology
Copyright (c) 2016-2026 KTH Royal Institute of Technology

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
19 changes: 10 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
# @kth/server

A wrapper around express.
In it's most basic usage, it just exposes an express app, but it has support for starting with ssl.
A wrapper around Express.

In its most basic usage, it exposes an Express app, but it also supports starting with SSL.

## Requirements

- Node.js `>=24`

## Simple usage, starts a server on http

Expand All @@ -15,7 +20,7 @@ app.start()
})
```

The import returns an Express.js instance, so you can add middleware and functions just as in a normal express app:
The import returns an Express.js instance, so you can add middleware and functions just as in a normal Express app:

```JavaScript
app.get('/', function (req, res) {
Expand Down Expand Up @@ -63,16 +68,12 @@ const optionsForSsl = {
app.start(optionsForSsl)
```

## Creating a self signed cert for testing
## Creating a self-signed cert for testing

```
$ openssl genrsa 2048 > test/certs/private.pem
$ openssl req -x509 -days 1000 -new -key test/certs/private.pem -out test/certs/public.pem -subj "/C=SE/ST=SWEDEN/L=Provo/O=kth-node-server/CN=www.test.com"
$ openssl req -x509 -days 1000 -new -key test/certs/private.pem -out test/certs/public.pem -subj "/C=SE/ST=SWEDEN/L=Stockholm/O=kth-node-server/CN=www.test.com"
$ openssl pkcs12 -export -in test/certs/public.pem -inkey test/certs/private.pem -passout pass:test -out test/certs/withpassphrase.pfx
$ echo 'test' >> test/certs/passphrase.txt
$ rm test/certs/private.pem test/certs/public.pem
```

## TODO

TODO: write test for signing requests with cert
8 changes: 8 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const kthConfig = require('@kth/eslint-config-kth')

module.exports = [
...kthConfig,
{
ignores: ['node_modules/**'],
},
]
31 changes: 24 additions & 7 deletions index.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict'

const path = require('path')
const fetch = require('node-fetch')
const https = require('https')
const server = require('./index')

Expand All @@ -21,6 +20,29 @@ server.use('/test', (req, res, next) =>
})
)

function httpsGetJson(url) {
return new Promise((resolve, reject) => {
// Allow self-signed certificates for testing purposes
const req = https.get(url, { rejectUnauthorized: false }, res => {
let body = ''

res.on('data', chunk => {
body += chunk
})

res.on('end', () => {
try {
resolve(JSON.parse(body))
} catch (error) {
reject(error)
}
})
})

req.on('error', reject)
})
}

describe('HTTP Server', () => {
afterAll(() => jest.resetAllMocks())

Expand Down Expand Up @@ -52,12 +74,7 @@ describe('HTTP Server', () => {
logger,
})

const agent = new https.Agent({
rejectUnauthorized: false,
})

const res = await fetch('https://localhost:9090/test', { agent })
const json = await res.json()
const json = await httpsGetJson('https://localhost:9090/test')
expect(json).not.toBeUndefined()
expect(json.status).toBe('ok')
})
Expand Down
7 changes: 0 additions & 7 deletions npm.conf

This file was deleted.

Loading