This is project is meant for learning, practicing and trying out things, not for use in a productive environment.
- Node 22.17.1
Certificates for development can be created with openssl:
openssl req -x509 -out localhost.crt -keyout localhost.key \
-newkey rsa:2048 -nodes -sha256 \
-subj '/CN=localhost' -extensions EXT -config <( \
printf "[dn]\nCN=localhost\n[req]\ndistinguished_name = dn\n[EXT]\nsubjectAltName=DNS:localhost\nkeyUsage=digitalSignature\nextendedKeyUsage=serverAuth")
From Let's encrypt: Certificates for localhost
Create a file config.json in the root directory of the project. The file should contain HttpsOptions with the paths to
the key and certificate files:
{
"HttpsOptions": {
"key": "path/to/localhost.key",
"cert": "path/to/localhost.crt"
}
}
The server will exit immediately if the config file is missing or the paths are invalid.
This repository contains a Dockerfile to build a container with the task service. To build the container, run the following
docker build -t task-service .
To run the container, use the following command:
In Bash
docker run \
--rm \
--detach \
--name task-service \
--publish 3000:3000 \
--volume tasks:/var/lib/task-service \
--volume ${PWD}/tasks.json:/etc/task-service/tasks.json:ro \
--volume ${PWD}/localhost.key:/etc/task-service/certs/localhost.key:ro \
--volume ${PWD}/localhost.crt:/etc/task-service/certs/localhost.crt:ro \
task-serviceIn PowerShell
docker run `
--rm `
--detach `
--name task-service `
--publish 3000:3000 `
--volume tasks:/var/lib/task-service `
--volume ${PWD}/tasks.json:/etc/task-service/tasks.json:ro `
--volume ${PWD}/localhost.key:/etc/task-service/certs/localhost.key:ro `
--volume ${PWD}/localhost.crt:/etc/task-service/certs/localhost.crt:ro `
--env TASK_TLS_KEY=/etc/task-service/certs/localhost.key `
--env TASK_TLS_CERT=/etc/task-service/certs/localhost.crt `
task-serviceThe container will be available on port 3000.
- Supports HTTPS
- Authentication
- Basic
- Not much more yet 😃
This describes some tests I'm running
node --test "**/*.test.js"Credentials are stored in a SecureString, I create one per session interactively with Get-Credential.
$credential = Get-CredentialCreate a minimal new task
Invoke-WebRequest "http://localhost:3000/task" -Credential $credential -AllowUnencryptedAuthentication -Method Post -Body '{"title": "New Task"}'Get all tasks
Invoke-WebRequest "http://localhost:3000/task" -Credential $credential -AllowUnencryptedAuthenticationGet a task
Invoke-WebRequest "http://localhost:3000/task/99e587e6-6550-4601-9e2a-d40d2a2dce7b" -Credential $credential -AllowUnencryptedAuthenticationUpdate a task
Invoke-WebRequest "http://localhost:3000/task/99e587e6-6550-4601-9e2a-d40d2a2dce7b" -Credential $credential -AllowUnencryptedAuthentication -Method Put -Body '{"done": true}'Delete a task
Invoke-WebRequest "http://localhost:3000/task/99e587e6-6550-4601-9e2a-d40d2a2dce7b" -Credential $credential -AllowUnencryptedAuthentication -Method Delete