@mongoosejs/studio 0.0.78 → 0.0.80
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 +86 -2
- package/frontend/src/routes.js +1 -1
- package/package.json +7 -1
package/README.md
CHANGED
|
@@ -1,2 +1,86 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
1
|
+
# Mongoose Studio
|
|
2
|
+
|
|
3
|
+
A sleek, powerful MongoDB UI with built-in dashboarding and auth, seamlessly integrated with your Express, Vercel, or Netlify app.
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
## Getting Started
|
|
8
|
+
|
|
9
|
+
Mongoose Studio is meant to run as a [sidecar](https://learn.microsoft.com/en-us/azure/architecture/patterns/sidecar) to your Node.js application, using the same Mongoose connection config.
|
|
10
|
+
If your app runs on `acme.app`, Studio will be on `acme.app/studio` or whichever path you prefer.
|
|
11
|
+
For local dev, if your app runs on `localhost:3000`, Studio will be on `localhost:3000/studio`.
|
|
12
|
+
|
|
13
|
+
By default, Mongoose Studio does **not** provide any authentication or authorization.
|
|
14
|
+
You can use Mongoose Studio for free for local development, but we recommend [Mongoose Studio Pro](https://studio.mongoosejs.io/#pricing) for when you want to go into production.
|
|
15
|
+
|
|
16
|
+
First, `npm install @mongoosejs/studio`.
|
|
17
|
+
|
|
18
|
+
### Express
|
|
19
|
+
|
|
20
|
+
Mongoose Studio can be mounted as Express middleware as follows.
|
|
21
|
+
|
|
22
|
+
```javascript
|
|
23
|
+
const mongoose = require('mongoose');
|
|
24
|
+
const studio = require('@mongoosejs/studio/express');
|
|
25
|
+
|
|
26
|
+
// Mount Mongoose Studio on '/studio'
|
|
27
|
+
// If your models are registered on a different connection, pass in the connection instead of `mongoose`
|
|
28
|
+
app.use('/studio', await studio('/studio/api', mongoose));
|
|
29
|
+
````
|
|
30
|
+
|
|
31
|
+
If you have a Mongoose Studio Pro API key, you can set it as follows:
|
|
32
|
+
|
|
33
|
+
```javascript
|
|
34
|
+
const opts = process.env.MONGOOSE_STUDIO_API_KEY ? { apiKey: process.env.MONGOOSE_STUDIO_API_KEY } : {};
|
|
35
|
+
|
|
36
|
+
// Mount Mongoose Studio on '/studio'
|
|
37
|
+
app.use('/studio', await studio('/studio/api', mongoose, opts));
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Netlify
|
|
41
|
+
|
|
42
|
+
[Here is a full example of how to add Mongoose Studio to a Netlify repo](https://github.com/mongoosejs/studio.mongoosejs.io/commit/8b02ea367c8a1b7b4bcab290708f57d58f08210b).
|
|
43
|
+
|
|
44
|
+
1) Copy the Mongoose Studio frontend into `public/studio` automatically in `npm run build`.
|
|
45
|
+
|
|
46
|
+
```javascript
|
|
47
|
+
const { execSync } = require('child_process');
|
|
48
|
+
|
|
49
|
+
// Sign up for Mongoose Studio Pro to get an API key, or omit `apiKey` for local dev.
|
|
50
|
+
const opts = {
|
|
51
|
+
apiKey: process.env.MONGOOSE_STUDIO_API_KEY
|
|
52
|
+
};
|
|
53
|
+
console.log('Creating Mongoose studio', opts);
|
|
54
|
+
require('@mongoosejs/studio/frontend')(`/.netlify/functions/studio`, true, opts).then(() => {
|
|
55
|
+
execSync(`
|
|
56
|
+
mkdir -p ./public/imdb
|
|
57
|
+
cp -r ./node_modules/@mongoosejs/studio/frontend/public/* ./public/imdb/
|
|
58
|
+
`);
|
|
59
|
+
});
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
2) Create a `/studio` Netlify function in `netlify/functions/studio.js`, or wherever your Netlify functions directory is. The function path should match the `/.netlify/functions/studio` parameter in the build script above.
|
|
63
|
+
|
|
64
|
+
```javascript
|
|
65
|
+
const mongoose = require('mongoose');
|
|
66
|
+
|
|
67
|
+
const handler = require('@mongoosejs/studio/backend/netlify')({
|
|
68
|
+
apiKey: process.env.MONGOOSE_STUDIO_API_KEY
|
|
69
|
+
}).handler;
|
|
70
|
+
|
|
71
|
+
let conn = null;
|
|
72
|
+
|
|
73
|
+
module.exports = {
|
|
74
|
+
handler: async function studioHandler(params) {
|
|
75
|
+
if (conn == null) {
|
|
76
|
+
conn = await mongoose.connect(process.env.MONGODB_CONNECTION_STRING, { serverSelectionTimeoutMS: 3000 });
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return handler.apply(null, arguments);
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
3) Redeploy and you're live!
|
|
85
|
+
|
|
86
|
+
Try [our IMDB demo](https://studio.mongoosejs.io/imdb/#/) for an example of Mongoose Studio running on Netlify, or check out the [studio.mongoosejs.io GitHub repo](https://github.com/mongoosejs/studio.mongoosejs.io) for the full source code.
|
package/frontend/src/routes.js
CHANGED
|
@@ -5,7 +5,7 @@ const roleAccess = {
|
|
|
5
5
|
owner: ['root', 'model', 'document', 'dashboards', 'dashboard', 'team', 'chat'],
|
|
6
6
|
admin: ['root', 'model', 'document', 'dashboards', 'dashboard', 'team', 'chat'],
|
|
7
7
|
member: ['root', 'model', 'document', 'dashboards', 'dashboard', 'chat'],
|
|
8
|
-
readonly: ['root', 'model', 'document'],
|
|
8
|
+
readonly: ['root', 'model', 'document', 'chat'],
|
|
9
9
|
dashboards: ['dashboards', 'dashboard']
|
|
10
10
|
};
|
|
11
11
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mongoosejs/studio",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.80",
|
|
4
|
+
"description": "A sleek, powerful MongoDB UI with built-in dashboarding and auth, seamlessly integrated with your Express, Vercel, or Netlify app.",
|
|
5
|
+
"homepage": "https://studio.mongoosejs.io/",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/mongoosejs/studio"
|
|
9
|
+
},
|
|
4
10
|
"dependencies": {
|
|
5
11
|
"archetype": "0.13.1",
|
|
6
12
|
"csv-stringify": "6.3.0",
|