sails-hook-slipway 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +109 -0
- package/index.js +101 -0
- package/package.json +35 -0
package/README.md
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# sails-hook-slipway
|
|
2
|
+
|
|
3
|
+
> The Sails hook that makes your app Slipway-aware
|
|
4
|
+
|
|
5
|
+
## What It Does
|
|
6
|
+
|
|
7
|
+
This hook transforms any Sails app into a fully-managed application with:
|
|
8
|
+
|
|
9
|
+
- **The Bridge** - Auto-generated CRUD for all your models (ship's command center)
|
|
10
|
+
- **The Helm** - Production REPL with full Sails context (where you steer your app)
|
|
11
|
+
- **Quest Dashboard** - Job queue management (if sails-quest installed)
|
|
12
|
+
- **Content CMS** - Visual content editor (if sails-content installed)
|
|
13
|
+
- **Telemetry** - OpenTelemetry instrumentation sent to Slipway
|
|
14
|
+
|
|
15
|
+
## Routes
|
|
16
|
+
|
|
17
|
+
| Route | Feature | Condition |
|
|
18
|
+
|-------|---------|-----------|
|
|
19
|
+
| `/slipway` | Control panel dashboard | Always |
|
|
20
|
+
| `/slipway/bridge` | The Bridge (data management) | Always |
|
|
21
|
+
| `/slipway/helm` | The Helm (REPL) | Always |
|
|
22
|
+
| `/slipway/quest` | Job queue dashboard | If sails-quest detected |
|
|
23
|
+
| `/slipway/content` | CMS interface | If sails-content detected |
|
|
24
|
+
|
|
25
|
+
## Two Access Methods
|
|
26
|
+
|
|
27
|
+
### 1. Direct (via app URL)
|
|
28
|
+
```
|
|
29
|
+
myapp.example.com/slipway/bridge
|
|
30
|
+
myapp.example.com/slipway/helm
|
|
31
|
+
```
|
|
32
|
+
Users go directly to your app's Bridge or Helm.
|
|
33
|
+
|
|
34
|
+
### 2. Via Slipway Dashboard (centralized)
|
|
35
|
+
```
|
|
36
|
+
slipway.yourdomain.com/app/myapp/bridge
|
|
37
|
+
slipway.yourdomain.com/app/myapp/helm
|
|
38
|
+
```
|
|
39
|
+
The Slipway Dashboard proxies requests, providing single sign-on across all apps.
|
|
40
|
+
|
|
41
|
+
## Installation
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
npm install sails-hook-slipway
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
The hook auto-registers with Sails.
|
|
48
|
+
|
|
49
|
+
## Configuration
|
|
50
|
+
|
|
51
|
+
```javascript
|
|
52
|
+
// config/slipway.js
|
|
53
|
+
module.exports.slipway = {
|
|
54
|
+
bridge: {
|
|
55
|
+
enabled: true,
|
|
56
|
+
path: '/slipway/bridge'
|
|
57
|
+
},
|
|
58
|
+
helm: {
|
|
59
|
+
enabled: true,
|
|
60
|
+
path: '/slipway/helm',
|
|
61
|
+
readOnly: false // Set true in production
|
|
62
|
+
},
|
|
63
|
+
quest: {
|
|
64
|
+
enabled: true // Auto-disabled if sails-quest not installed
|
|
65
|
+
},
|
|
66
|
+
content: {
|
|
67
|
+
enabled: true // Auto-disabled if sails-content not installed
|
|
68
|
+
},
|
|
69
|
+
telemetry: {
|
|
70
|
+
enabled: true,
|
|
71
|
+
endpoint: process.env.SLIPWAY_TELEMETRY_URL
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Permissions (Sails Clearance)
|
|
77
|
+
|
|
78
|
+
The hook integrates with Sails Clearance for fine-grained access control:
|
|
79
|
+
|
|
80
|
+
```javascript
|
|
81
|
+
{
|
|
82
|
+
'bridge:read': ['admin', 'support'],
|
|
83
|
+
'bridge:write': ['admin'],
|
|
84
|
+
'helm:access': ['admin', 'developer'],
|
|
85
|
+
'quest:retry': ['admin', 'developer'],
|
|
86
|
+
'content:publish': ['admin', 'editor']
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Dev Mode
|
|
91
|
+
|
|
92
|
+
When you run `slipway dev`, this hook provides the full experience locally:
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
slipway dev
|
|
96
|
+
|
|
97
|
+
App: http://localhost:1337
|
|
98
|
+
Bridge: http://localhost:1337/slipway/bridge
|
|
99
|
+
Helm: http://localhost:1337/slipway/helm
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Part of the Slipway Suite
|
|
103
|
+
|
|
104
|
+
- **Slipway Dashboard** - Can proxy to this hook's routes
|
|
105
|
+
- **slipway CLI** - `slipway helm` connects to this hook
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
*Where your apps slide into production.*
|
package/index.js
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* sails-hook-slipway
|
|
3
|
+
*
|
|
4
|
+
* Provides admin panel, console (REPL), and telemetry for Sails apps
|
|
5
|
+
* deployed with Slipway.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
module.exports = function defineSlipwayHook(sails) {
|
|
9
|
+
return {
|
|
10
|
+
defaults: {
|
|
11
|
+
slipway: {
|
|
12
|
+
// Enable/disable features
|
|
13
|
+
admin: {
|
|
14
|
+
enabled: true,
|
|
15
|
+
path: '/_slipway/admin'
|
|
16
|
+
},
|
|
17
|
+
console: {
|
|
18
|
+
enabled: true,
|
|
19
|
+
path: '/_slipway/console'
|
|
20
|
+
},
|
|
21
|
+
telemetry: {
|
|
22
|
+
enabled: true,
|
|
23
|
+
endpoint: process.env.SLIPWAY_TELEMETRY_URL || null
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
|
|
28
|
+
configure: function () {
|
|
29
|
+
// Expose slipway config
|
|
30
|
+
sails.config.slipway = sails.config.slipway || {}
|
|
31
|
+
},
|
|
32
|
+
|
|
33
|
+
initialize: async function () {
|
|
34
|
+
const config = sails.config.slipway
|
|
35
|
+
|
|
36
|
+
sails.log.info('sails-hook-slipway: Initializing...')
|
|
37
|
+
|
|
38
|
+
// Initialize telemetry if configured
|
|
39
|
+
if (config.telemetry.enabled && config.telemetry.endpoint) {
|
|
40
|
+
await this.initTelemetry(config.telemetry)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
sails.log.info('sails-hook-slipway: Ready')
|
|
44
|
+
},
|
|
45
|
+
|
|
46
|
+
initTelemetry: async function (telemetryConfig) {
|
|
47
|
+
try {
|
|
48
|
+
// OpenTelemetry setup will go here
|
|
49
|
+
sails.log.verbose('sails-hook-slipway: Telemetry initialized')
|
|
50
|
+
} catch (err) {
|
|
51
|
+
sails.log.warn('sails-hook-slipway: Failed to initialize telemetry:', err.message)
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
|
|
55
|
+
routes: {
|
|
56
|
+
before: {
|
|
57
|
+
// Admin panel
|
|
58
|
+
'GET /_slipway/admin': function (req, res, next) {
|
|
59
|
+
if (!sails.config.slipway.admin.enabled) {
|
|
60
|
+
return next()
|
|
61
|
+
}
|
|
62
|
+
// TODO: Render admin panel
|
|
63
|
+
res.json({ message: 'Slipway Admin Panel - Coming Soon' })
|
|
64
|
+
},
|
|
65
|
+
|
|
66
|
+
// Console (REPL)
|
|
67
|
+
'GET /_slipway/console': function (req, res, next) {
|
|
68
|
+
if (!sails.config.slipway.console.enabled) {
|
|
69
|
+
return next()
|
|
70
|
+
}
|
|
71
|
+
// TODO: Render console
|
|
72
|
+
res.json({ message: 'Slipway Console - Coming Soon' })
|
|
73
|
+
},
|
|
74
|
+
|
|
75
|
+
// Health check for Slipway
|
|
76
|
+
'GET /_slipway/health': function (req, res) {
|
|
77
|
+
res.json({
|
|
78
|
+
status: 'ok',
|
|
79
|
+
sails: sails.config.environment,
|
|
80
|
+
uptime: process.uptime()
|
|
81
|
+
})
|
|
82
|
+
},
|
|
83
|
+
|
|
84
|
+
// Models list (for admin panel)
|
|
85
|
+
'GET /_slipway/api/models': function (req, res, next) {
|
|
86
|
+
if (!sails.config.slipway.admin.enabled) {
|
|
87
|
+
return next()
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const models = Object.keys(sails.models).map(identity => ({
|
|
91
|
+
identity,
|
|
92
|
+
globalId: sails.models[identity].globalId,
|
|
93
|
+
attributes: Object.keys(sails.models[identity].attributes)
|
|
94
|
+
}))
|
|
95
|
+
|
|
96
|
+
res.json({ models })
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "sails-hook-slipway",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"description": "Sails hook for Slipway - admin panel, console, and telemetry",
|
|
5
|
+
"keywords": ["sails", "hook", "admin", "slipway"],
|
|
6
|
+
"main": "index.js",
|
|
7
|
+
"sails": {
|
|
8
|
+
"isHook": true,
|
|
9
|
+
"hookName": "slipway"
|
|
10
|
+
},
|
|
11
|
+
"scripts": {
|
|
12
|
+
"test": "echo \"TODO: add tests\""
|
|
13
|
+
},
|
|
14
|
+
"dependencies": {},
|
|
15
|
+
"peerDependencies": {
|
|
16
|
+
"sails": "^1.5.0"
|
|
17
|
+
},
|
|
18
|
+
"peerDependenciesMeta": {
|
|
19
|
+
"sails-quest": {
|
|
20
|
+
"optional": true
|
|
21
|
+
},
|
|
22
|
+
"sails-content": {
|
|
23
|
+
"optional": true
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"engines": {
|
|
27
|
+
"node": ">=18.0"
|
|
28
|
+
},
|
|
29
|
+
"license": "MIT",
|
|
30
|
+
"repository": {
|
|
31
|
+
"type": "git",
|
|
32
|
+
"url": "https://github.com/sailscastshq/slipway.git",
|
|
33
|
+
"directory": "packages/hook"
|
|
34
|
+
}
|
|
35
|
+
}
|