Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: express plugin, deploy plugin #178

Merged
merged 23 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
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
6 changes: 6 additions & 0 deletions .changeset/dirty-mugs-bow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@kopflos-cms/plugin-deploy-resources": minor
"@kopflos-cms/plugin-express": minor
---

First version
2 changes: 1 addition & 1 deletion .changeset/real-numbers-visit.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
"@kopflos-cms/express": minor
---

The main export now returns and object `{ middleware: RequestHandler; instance: Kopflos }`
The main export now returns `Promise<{ middleware: RequestHandler; instance: Kopflos }>`
5 changes: 5 additions & 0 deletions .changeset/slimy-frogs-tie.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@kopflos-cms/core": patch
---

Object of `kl:handler` can now be an RDF List of handler implementations which will be called in sequence
7 changes: 7 additions & 0 deletions .changeset/stupid-ads-destroy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@kopflos-cms/express": patch
"@kopflos-cms/core": patch
"kopflos": patch
---

Added plugin with `onStart` hook
6 changes: 6 additions & 0 deletions .changeset/tame-cobras-leave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@kopflos-cms/plugin-express": minor
"@kopflos-cms/express": minor
---

Added express-only middleware hooks
5 changes: 5 additions & 0 deletions .changeset/thin-penguins-greet.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@kopflos-cms/core": patch
---

Added `./env.js` to package exports
2 changes: 1 addition & 1 deletion codecov.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
ignore:
- packages/mocha-chai-rdf
- example
2 changes: 1 addition & 1 deletion example/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: '2'
services:
oxigraph:
image: ghcr.io/oxigraph/oxigraph:0.4.0-rc.1
image: ghcr.io/oxigraph/oxigraph:0.4.1
user: root
command: serve --location /data --bind 0.0.0.0:7878
ports:
Expand Down
14 changes: 13 additions & 1 deletion example/kopflos.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as url from 'node:url'
import type { KopflosConfig } from '@kopflos-cms/core'

export default <KopflosConfig> {
deploy: ['resources', 'resources.dev'],
baseIri: 'http://localhost:1429',
apiGraphs: ['http://localhost:1429/api'],
sparql: {
Expand All @@ -10,4 +10,16 @@ export default <KopflosConfig> {
updateUrl: 'http://localhost:7878/update',
},
},
plugins: {
'@kopflos-cms/plugin-deploy-resources': {
paths: ['resources', 'resources.dev'],
},
'@kopflos-cms/express/middleware': {
before: [
'cors',
['compression', { level: 0 }],
url.fileURLToPath(new URL('.', import.meta.url) + 'lib/static.js'),
],
},
},
}
5 changes: 5 additions & 0 deletions example/lib/static.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import express from 'express'

export default (): express.RequestHandler => {
return express.static('public')
}
10 changes: 8 additions & 2 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,15 @@
"private": true,
"type": "module",
"scripts": {
"start": "kopflos serve"
"start": "kopflos serve --trust-proxy"
},
"dependencies": {
"kopflos": "*"
"express": "^4.21.0",
"kopflos": "*",
"cors": "^2.8.5",
"compression": "^1.7.4"
},
"devDependencies": {
"@types/express": "^4.17.21"
}
}
1 change: 1 addition & 0 deletions example/public/foo.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bar
181 changes: 157 additions & 24 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions packages/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ Options:
-c, --config <config> Path to config file
-p, --port <port> Port to listen on (default: 1429)
-h, --host <host> Host to bind to (default: "0.0.0.0")
--deploy <paths...> Resource paths to be deployed
--auto-deploy Deploy resources from the resources directory (default: true)
--no-auto-deploy Disable auto deployment
--help display help for command
```

Expand Down
Loading