create-cedar-app 0.7.2-next.2 → 0.7.2-next.50
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/dist/create-cedar-app.js +94 -94
- package/package.json +7 -6
- package/templates/esm-js/.editorconfig +10 -0
- package/templates/esm-js/.env +15 -0
- package/templates/esm-js/.env.defaults +19 -0
- package/templates/esm-js/.env.example +4 -0
- package/templates/esm-js/.redwood/README.md +44 -0
- package/templates/esm-js/.vscode/extensions.json +14 -0
- package/templates/esm-js/.vscode/launch.json +56 -0
- package/templates/esm-js/.vscode/settings.json +11 -0
- package/templates/esm-js/.vscode/tasks.json +29 -0
- package/templates/esm-js/.yarnrc.yml +15 -0
- package/templates/esm-js/README.md +17 -0
- package/templates/esm-js/api/db/schema.prisma +24 -0
- package/templates/esm-js/api/jsconfig.json +41 -0
- package/templates/esm-js/api/package.json +10 -0
- package/templates/esm-js/api/src/directives/requireAuth/requireAuth.js +22 -0
- package/templates/esm-js/api/src/directives/requireAuth/requireAuth.test.js +18 -0
- package/templates/esm-js/api/src/directives/skipAuth/skipAuth.js +16 -0
- package/templates/esm-js/api/src/directives/skipAuth/skipAuth.test.js +10 -0
- package/templates/esm-js/api/src/functions/graphql.js +19 -0
- package/templates/esm-js/api/src/graphql/.keep +0 -0
- package/templates/esm-js/api/src/lib/auth.js +32 -0
- package/templates/esm-js/api/src/lib/db.js +26 -0
- package/templates/esm-js/api/src/lib/logger.js +17 -0
- package/templates/esm-js/api/src/services/.keep +0 -0
- package/templates/esm-js/api/vitest.config.js +10 -0
- package/templates/esm-js/gitignore.template +24 -0
- package/templates/esm-js/graphql.config.cjs +11 -0
- package/templates/esm-js/package.json +32 -0
- package/templates/esm-js/prettier.config.cjs +18 -0
- package/templates/esm-js/redwood.toml +21 -0
- package/templates/esm-js/scripts/.keep +0 -0
- package/templates/esm-js/scripts/jsconfig.json +54 -0
- package/templates/esm-js/scripts/seed.js +27 -0
- package/templates/esm-js/vitest.config.mjs +7 -0
- package/templates/esm-js/web/jsconfig.json +53 -0
- package/templates/esm-js/web/package.json +26 -0
- package/templates/esm-js/web/public/README.md +43 -0
- package/templates/esm-js/web/public/favicon.png +0 -0
- package/templates/esm-js/web/public/robots.txt +2 -0
- package/templates/esm-js/web/src/App.jsx +16 -0
- package/templates/esm-js/web/src/Routes.jsx +20 -0
- package/templates/esm-js/web/src/components/.keep +0 -0
- package/templates/esm-js/web/src/entry.client.jsx +35 -0
- package/templates/esm-js/web/src/index.css +0 -0
- package/templates/esm-js/web/src/index.html +15 -0
- package/templates/esm-js/web/src/layouts/.keep +0 -0
- package/templates/esm-js/web/src/pages/FatalErrorPage/FatalErrorPage.jsx +58 -0
- package/templates/esm-js/web/src/pages/NotFoundPage/NotFoundPage.jsx +45 -0
- package/templates/esm-js/web/vite.config.js +21 -0
- package/templates/esm-js/web/vitest.setup.js +12 -0
- package/templates/esm-ts/.editorconfig +10 -0
- package/templates/esm-ts/.env +15 -0
- package/templates/esm-ts/.env.defaults +19 -0
- package/templates/esm-ts/.env.example +4 -0
- package/templates/esm-ts/.redwood/README.md +44 -0
- package/templates/esm-ts/.vscode/extensions.json +14 -0
- package/templates/esm-ts/.vscode/launch.json +56 -0
- package/templates/esm-ts/.vscode/settings.json +11 -0
- package/templates/esm-ts/.vscode/tasks.json +29 -0
- package/templates/esm-ts/.yarnrc.yml +15 -0
- package/templates/esm-ts/README.md +17 -0
- package/templates/esm-ts/api/db/schema.prisma +24 -0
- package/templates/esm-ts/api/package.json +10 -0
- package/templates/esm-ts/api/src/directives/requireAuth/requireAuth.test.ts +18 -0
- package/templates/esm-ts/api/src/directives/requireAuth/requireAuth.ts +25 -0
- package/templates/esm-ts/api/src/directives/skipAuth/skipAuth.test.ts +10 -0
- package/templates/esm-ts/api/src/directives/skipAuth/skipAuth.ts +16 -0
- package/templates/esm-ts/api/src/functions/graphql.ts +19 -0
- package/templates/esm-ts/api/src/graphql/.keep +0 -0
- package/templates/esm-ts/api/src/lib/auth.ts +32 -0
- package/templates/esm-ts/api/src/lib/db.ts +26 -0
- package/templates/esm-ts/api/src/lib/logger.ts +17 -0
- package/templates/esm-ts/api/src/services/.keep +0 -0
- package/templates/esm-ts/api/tsconfig.json +26 -0
- package/templates/esm-ts/api/vitest.config.ts +10 -0
- package/templates/esm-ts/gitignore.template +24 -0
- package/templates/esm-ts/graphql.config.cjs +11 -0
- package/templates/esm-ts/package.json +32 -0
- package/templates/esm-ts/prettier.config.cjs +18 -0
- package/templates/esm-ts/redwood.toml +21 -0
- package/templates/esm-ts/scripts/.keep +0 -0
- package/templates/esm-ts/scripts/seed.ts +27 -0
- package/templates/esm-ts/scripts/tsconfig.json +29 -0
- package/templates/esm-ts/vitest.config.ts +7 -0
- package/templates/esm-ts/web/package.json +26 -0
- package/templates/esm-ts/web/public/README.md +43 -0
- package/templates/esm-ts/web/public/favicon.png +0 -0
- package/templates/esm-ts/web/public/robots.txt +2 -0
- package/templates/esm-ts/web/src/App.tsx +22 -0
- package/templates/esm-ts/web/src/Routes.tsx +20 -0
- package/templates/esm-ts/web/src/components/.keep +0 -0
- package/templates/esm-ts/web/src/entry.client.tsx +35 -0
- package/templates/esm-ts/web/src/index.css +0 -0
- package/templates/esm-ts/web/src/index.html +15 -0
- package/templates/esm-ts/web/src/layouts/.keep +0 -0
- package/templates/esm-ts/web/src/pages/FatalErrorPage/FatalErrorPage.tsx +57 -0
- package/templates/esm-ts/web/src/pages/NotFoundPage/NotFoundPage.tsx +44 -0
- package/templates/esm-ts/web/tsconfig.json +44 -0
- package/templates/esm-ts/web/vite.config.ts +21 -0
- package/templates/esm-ts/web/vitest.setup.ts +12 -0
- package/templates/js/api/package.json +2 -2
- package/templates/js/package.json +3 -3
- package/templates/js/web/package.json +4 -4
- package/templates/ts/api/package.json +2 -2
- package/templates/ts/package.json +3 -3
- package/templates/ts/web/package.json +4 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-cedar-app",
|
|
3
|
-
"version": "0.7.2-next.
|
|
3
|
+
"version": "0.7.2-next.50+a096cc0c6",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/cedarjs/cedar.git",
|
|
@@ -26,25 +26,26 @@
|
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@babel/core": "^7.26.10",
|
|
28
28
|
"@babel/plugin-transform-typescript": "^7.26.8",
|
|
29
|
-
"@cedarjs/framework-tools": "0.7.2-next.
|
|
30
|
-
"@cedarjs/tui": "0.7.2-next.
|
|
29
|
+
"@cedarjs/framework-tools": "0.7.2-next.50",
|
|
30
|
+
"@cedarjs/tui": "0.7.2-next.50+a096cc0c6",
|
|
31
31
|
"@opentelemetry/api": "1.8.0",
|
|
32
32
|
"@opentelemetry/exporter-trace-otlp-http": "0.49.1",
|
|
33
33
|
"@opentelemetry/resources": "1.22.0",
|
|
34
34
|
"@opentelemetry/sdk-trace-node": "1.22.0",
|
|
35
35
|
"@opentelemetry/semantic-conventions": "1.22.0",
|
|
36
36
|
"@types/babel__core": "7.20.5",
|
|
37
|
+
"@types/klaw-sync": "6.0.5",
|
|
37
38
|
"ansis": "4.1.0",
|
|
38
39
|
"check-node-version": "4.2.1",
|
|
39
40
|
"ci-info": "4.0.0",
|
|
40
41
|
"envinfo": "7.14.0",
|
|
41
42
|
"execa": "5.1.1",
|
|
42
43
|
"fs-extra": "11.2.0",
|
|
43
|
-
"klaw-sync": "
|
|
44
|
+
"klaw-sync": "7.0.0",
|
|
44
45
|
"semver": "7.6.3",
|
|
45
46
|
"systeminformation": "5.23.8",
|
|
46
47
|
"termi-link": "1.1.0",
|
|
47
|
-
"tsx": "4.20.
|
|
48
|
+
"tsx": "4.20.4",
|
|
48
49
|
"untildify": "4.0.0",
|
|
49
50
|
"uuid": "10.0.0",
|
|
50
51
|
"vitest": "3.2.4",
|
|
@@ -53,5 +54,5 @@
|
|
|
53
54
|
"publishConfig": {
|
|
54
55
|
"access": "public"
|
|
55
56
|
},
|
|
56
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "a096cc0c68ba5371661ed5ea0e11a0ad10f61a21"
|
|
57
58
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# THIS FILE SHOULD NOT BE CHECKED INTO YOUR VERSION CONTROL SYSTEM
|
|
2
|
+
#
|
|
3
|
+
# Environment variables set here will override those in .env.defaults.
|
|
4
|
+
# Any environment variables you need in production you will need to setup with
|
|
5
|
+
# your hosting provider. For example in Netlify you can add environment
|
|
6
|
+
# variables in Settings > Build & Deploy > environment
|
|
7
|
+
#
|
|
8
|
+
# DATABASE_URL=postgres://user:pass@postgreshost.com:5432/database_name
|
|
9
|
+
# TEST_DATABASE_URL=postgres://user:pass@postgreshost.com:5432/test_database_name
|
|
10
|
+
#
|
|
11
|
+
# Sets an app-specific secret used to sign and verify your own app's webhooks.
|
|
12
|
+
# For example if you schedule a cron job with a signed payload that later will
|
|
13
|
+
# then invoke your api-side webhook function you will use this secret to sign and the verify.
|
|
14
|
+
# Important: Please change this default to a strong password or other secret
|
|
15
|
+
# WEBHOOK_SECRET=THIS_IS_NOT_SECRET_PLEASE_CHANGE
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# These environment variables will be used by default if you do not create any
|
|
2
|
+
# yourself in .env. This file should be safe to check into your version control
|
|
3
|
+
# system. Any custom values should go in .env and .env should *not* be checked
|
|
4
|
+
# into version control.
|
|
5
|
+
|
|
6
|
+
# schema.prisma defaults
|
|
7
|
+
DATABASE_URL=file:./dev.db
|
|
8
|
+
|
|
9
|
+
# location of the test database for api service scenarios (defaults to ./.redwood/test.db if not set)
|
|
10
|
+
# TEST_DATABASE_URL=file:./.redwood/test.db
|
|
11
|
+
|
|
12
|
+
# disables Prisma CLI update notifier
|
|
13
|
+
PRISMA_HIDE_UPDATE_MESSAGE=true
|
|
14
|
+
|
|
15
|
+
# Option to override the current environment's default api-side log level
|
|
16
|
+
# See: https://redwoodjs.com/docs/logger for level options, defaults to "trace" otherwise.
|
|
17
|
+
# Most applications want "debug" or "info" during dev, "trace" when you have issues and "warn" in production.
|
|
18
|
+
# Ordered by how verbose they are: trace | debug | info | warn | error | silent
|
|
19
|
+
# LOG_LEVEL=debug
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# .redwood
|
|
2
|
+
|
|
3
|
+
## What is this directory?
|
|
4
|
+
|
|
5
|
+
Redwood uses this `.redwood` directory to store transitory data that aids in the smooth and convenient operation of your Redwood project.
|
|
6
|
+
|
|
7
|
+
## Do I need to do anything with this directory?
|
|
8
|
+
|
|
9
|
+
No. You shouldn't have to create, edit or delete anything in this directory in your day-to-day work with Redwood.
|
|
10
|
+
|
|
11
|
+
You don't need to commit any other contents of this directory to your version control system. It's ignored by default.
|
|
12
|
+
|
|
13
|
+
## What's in this directory?
|
|
14
|
+
|
|
15
|
+
### Files
|
|
16
|
+
|
|
17
|
+
| Name | Description |
|
|
18
|
+
| :---------------- | :----------------------------------------------------------------------------------------------------------------- |
|
|
19
|
+
| commandCache.json | This file contains mappings to assist the Redwood CLI in efficiently executing commands. |
|
|
20
|
+
| schema.graphql | This is the GraphQL schema which has been automatically generated from your Redwood project. |
|
|
21
|
+
| telemetry.txt | Contains a unique ID used for telemetry. This value is rotated every 24 hours to protect your project's anonymity. |
|
|
22
|
+
| test.db | The sqlite database used when running tests. |
|
|
23
|
+
|
|
24
|
+
### Directories
|
|
25
|
+
|
|
26
|
+
| Name | Description |
|
|
27
|
+
| :---------- | :----------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
28
|
+
| locks | Stores temporary files that Redwood uses to keep track of the execution of async/background tasks between processes. |
|
|
29
|
+
| logs | Stores log files for background tasks such as update checking. |
|
|
30
|
+
| prebuild | Stores transpiled JavaScript that is generated as part of Redwood's build process. |
|
|
31
|
+
| telemetry | Stores the recent telemetry that the Redwood CLI has generated. You may inspect these files to see everything Redwood is anonymously collecting. |
|
|
32
|
+
| types | Stores the results of type generation. |
|
|
33
|
+
| updateCheck | Stores a file which contains the results of checking for Redwood updates. |
|
|
34
|
+
| studio | Used to store data for `rw studio` |
|
|
35
|
+
|
|
36
|
+
We try to keep this README up to date but you may, from time to time, find other files or directories in this `.redwood` directory that have not yet been documented here. This is likely nothing to worry about but feel free to let us know and we'll update this list.
|
|
37
|
+
|
|
38
|
+
### Telemetry
|
|
39
|
+
|
|
40
|
+
RedwoodJS collects completely anonymous telemetry data about general usage. For transparency, that data is viewable in the respective directories and files. To learn more and manage your project's settings, visit [telemetry.redwoodjs.com](https://telemetry.redwoodjs.com).
|
|
41
|
+
|
|
42
|
+
### Have any questions?
|
|
43
|
+
|
|
44
|
+
Feel free to reach out to us in the [RedwoodJS Community](https://community.redwoodjs.com/) forum if you have any questions.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"recommendations": [
|
|
3
|
+
"dbaeumer.vscode-eslint",
|
|
4
|
+
"eamodio.gitlens",
|
|
5
|
+
"ofhumanbondage.react-proptypes-intellisense",
|
|
6
|
+
"mgmcdermott.vscode-language-babel",
|
|
7
|
+
"wix.vscode-import-cost",
|
|
8
|
+
"pflannery.vscode-versionlens",
|
|
9
|
+
"editorconfig.editorconfig",
|
|
10
|
+
"prisma.prisma",
|
|
11
|
+
"graphql.vscode-graphql"
|
|
12
|
+
],
|
|
13
|
+
"unwantedRecommendations": []
|
|
14
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "0.3.0",
|
|
3
|
+
"configurations": [
|
|
4
|
+
{
|
|
5
|
+
"command": "yarn redwood dev --apiDebugPort 18911", // you can add --fwd='--open=false' to prevent the browser from opening
|
|
6
|
+
"name": "Run Dev Server",
|
|
7
|
+
"request": "launch",
|
|
8
|
+
"type": "node-terminal"
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"name": "Attach API debugger",
|
|
12
|
+
"port": 18911, // you can change this port, see https://redwoodjs.com/docs/project-configuration-dev-test-build#debugger-configuration
|
|
13
|
+
"request": "attach",
|
|
14
|
+
"skipFiles": [
|
|
15
|
+
"<node_internals>/**"
|
|
16
|
+
],
|
|
17
|
+
"type": "node",
|
|
18
|
+
"localRoot": "${workspaceFolder}/node_modules/@cedarjs/api-server/dist",
|
|
19
|
+
"remoteRoot": "${workspaceFolder}/node_modules/@cedarjs/api-server/dist",
|
|
20
|
+
"sourceMaps": true,
|
|
21
|
+
"restart": true,
|
|
22
|
+
"preLaunchTask": "WaitForDevServer",
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"name": "Launch Web debugger",
|
|
26
|
+
"type": "chrome",
|
|
27
|
+
"request": "launch",
|
|
28
|
+
"url": "http://localhost:8910",
|
|
29
|
+
"webRoot": "${workspaceRoot}/web/src",
|
|
30
|
+
"preLaunchTask": "WaitForDevServer",
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"command": "yarn redwood test api",
|
|
34
|
+
"name": "Test api",
|
|
35
|
+
"request": "launch",
|
|
36
|
+
"type": "node-terminal"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"command": "yarn redwood test web",
|
|
40
|
+
"name": "Test web",
|
|
41
|
+
"request": "launch",
|
|
42
|
+
"type": "node-terminal"
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
"compounds": [
|
|
46
|
+
{
|
|
47
|
+
"name": "Start Debug",
|
|
48
|
+
"configurations": [
|
|
49
|
+
"Run Dev Server",
|
|
50
|
+
"Attach API debugger",
|
|
51
|
+
"Launch Web debugger"
|
|
52
|
+
],
|
|
53
|
+
"stopAll": true
|
|
54
|
+
}
|
|
55
|
+
]
|
|
56
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "2.0.0",
|
|
3
|
+
"tasks": [
|
|
4
|
+
{
|
|
5
|
+
"label": "WaitForDevServer",
|
|
6
|
+
"group": "none",
|
|
7
|
+
"type": "shell",
|
|
8
|
+
"command": "bash",
|
|
9
|
+
"args": [
|
|
10
|
+
"-c",
|
|
11
|
+
"while ! echo -n > /dev/tcp/localhost/18911; do sleep 1; done;"
|
|
12
|
+
],
|
|
13
|
+
"windows": {
|
|
14
|
+
"command": "powershell",
|
|
15
|
+
"args": [
|
|
16
|
+
"-NoProfile",
|
|
17
|
+
"-ExecutionPolicy", "Bypass",
|
|
18
|
+
"while (-not (Test-NetConnection -ComputerName localhost -Port 18911)) { Start-Sleep -Seconds 1 };"
|
|
19
|
+
]
|
|
20
|
+
},
|
|
21
|
+
"presentation": {
|
|
22
|
+
"reveal": "silent",
|
|
23
|
+
"revealProblems": "onProblem",
|
|
24
|
+
"panel": "shared",
|
|
25
|
+
"close": true
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
]
|
|
29
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Yarn's manifest file. You can configure yarn here.
|
|
2
|
+
# See https://yarnpkg.com/configuration/yarnrc.
|
|
3
|
+
|
|
4
|
+
# For `node_modules` (see `nodeLinker` below), this is almost always the preferred option.
|
|
5
|
+
compressionLevel: 0
|
|
6
|
+
|
|
7
|
+
enableGlobalCache: true
|
|
8
|
+
|
|
9
|
+
# Lets yarn use hardlinks inside `node_modules` to dedupe packages.
|
|
10
|
+
# For a more pnpm-like experience, consider `hardlinks-global` where hardlinks point to a global store.
|
|
11
|
+
nmMode: hardlinks-local
|
|
12
|
+
|
|
13
|
+
# How to install Node packages.
|
|
14
|
+
# Heads up: right now, Redwood expects this to be `node-modules`.
|
|
15
|
+
nodeLinker: node-modules
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# README
|
|
2
|
+
|
|
3
|
+
Welcome to your new [CedarJS](https://cedarjs.com) project!
|
|
4
|
+
|
|
5
|
+
Start by installing dependencies:
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
yarn install
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Then start the development server:
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
yarn redwood dev
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Your browser should automatically open to [http://localhost:8910](http://localhost:8910) where you'll see the Welcome Page, which links out to many great resources.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// Don't forget to tell Prisma about your edits to this file using
|
|
2
|
+
// `yarn rw prisma migrate dev` or `yarn rw prisma db push`.
|
|
3
|
+
// `migrate` is like committing while `push` is for prototyping.
|
|
4
|
+
// Read more about both here:
|
|
5
|
+
// https://www.prisma.io/docs/orm/prisma-migrate
|
|
6
|
+
|
|
7
|
+
datasource db {
|
|
8
|
+
provider = "sqlite"
|
|
9
|
+
url = env("DATABASE_URL")
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
generator client {
|
|
13
|
+
provider = "prisma-client-js"
|
|
14
|
+
binaryTargets = "native"
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// Define your own datamodels here and run `yarn redwood prisma migrate dev`
|
|
18
|
+
// to create migrations for them and apply to your dev DB.
|
|
19
|
+
// TODO: Please remove the following example:
|
|
20
|
+
model UserExample {
|
|
21
|
+
id Int @id @default(autoincrement())
|
|
22
|
+
email String @unique
|
|
23
|
+
name String?
|
|
24
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"noEmit": true,
|
|
4
|
+
"esModuleInterop": true,
|
|
5
|
+
"target": "ES2023",
|
|
6
|
+
"module": "Node16",
|
|
7
|
+
"moduleResolution": "Node16",
|
|
8
|
+
"skipLibCheck": false,
|
|
9
|
+
"rootDirs": [
|
|
10
|
+
"./src",
|
|
11
|
+
"../.redwood/types/mirror/api/src"
|
|
12
|
+
],
|
|
13
|
+
"paths": {
|
|
14
|
+
"src/*": [
|
|
15
|
+
"./src/*",
|
|
16
|
+
"../.redwood/types/mirror/api/src/*"
|
|
17
|
+
],
|
|
18
|
+
"types/*": [
|
|
19
|
+
"./types/*",
|
|
20
|
+
"../types/*"
|
|
21
|
+
],
|
|
22
|
+
"@cedarjs/testing": [
|
|
23
|
+
"../node_modules/@cedarjs/testing/api"
|
|
24
|
+
]
|
|
25
|
+
},
|
|
26
|
+
"typeRoots": [
|
|
27
|
+
"../node_modules/@types",
|
|
28
|
+
"./node_modules/@types"
|
|
29
|
+
],
|
|
30
|
+
"types": [
|
|
31
|
+
"jest"
|
|
32
|
+
],
|
|
33
|
+
"jsx": "react-jsx"
|
|
34
|
+
},
|
|
35
|
+
"include": [
|
|
36
|
+
"src",
|
|
37
|
+
"../.redwood/types/includes/all-*",
|
|
38
|
+
"../.redwood/types/includes/api-*",
|
|
39
|
+
"../types"
|
|
40
|
+
]
|
|
41
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { gql } from 'graphql-tag'
|
|
2
|
+
|
|
3
|
+
import { createValidatorDirective } from '@cedarjs/graphql-server'
|
|
4
|
+
|
|
5
|
+
import { requireAuth as applicationRequireAuth } from 'src/lib/auth.js'
|
|
6
|
+
|
|
7
|
+
export const schema = gql`
|
|
8
|
+
"""
|
|
9
|
+
Use to check whether or not a user is authenticated and is associated
|
|
10
|
+
with an optional set of roles.
|
|
11
|
+
"""
|
|
12
|
+
directive @requireAuth(roles: [String]) on FIELD_DEFINITION
|
|
13
|
+
`
|
|
14
|
+
|
|
15
|
+
const validate = ({ directiveArgs }) => {
|
|
16
|
+
const { roles } = directiveArgs
|
|
17
|
+
applicationRequireAuth({ roles })
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const requireAuth = createValidatorDirective(schema, validate)
|
|
21
|
+
|
|
22
|
+
export default requireAuth
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { mockRedwoodDirective, getDirectiveName } from '@cedarjs/testing/api'
|
|
2
|
+
|
|
3
|
+
import requireAuth from './requireAuth.js'
|
|
4
|
+
|
|
5
|
+
describe('requireAuth directive', () => {
|
|
6
|
+
it('declares the directive sdl as schema, with the correct name', () => {
|
|
7
|
+
expect(requireAuth.schema).toBeTruthy()
|
|
8
|
+
expect(getDirectiveName(requireAuth.schema)).toBe('requireAuth')
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
it('requireAuth has stub implementation. Should not throw when current user', () => {
|
|
12
|
+
// If you want to set values in context, pass it through e.g.
|
|
13
|
+
// mockRedwoodDirective(requireAuth, { context: { currentUser: { id: 1, name: 'Lebron McGretzky' } }})
|
|
14
|
+
const mockExecution = mockRedwoodDirective(requireAuth, { context: {} })
|
|
15
|
+
|
|
16
|
+
expect(mockExecution).not.toThrowError()
|
|
17
|
+
})
|
|
18
|
+
})
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { gql } from 'graphql-tag'
|
|
2
|
+
|
|
3
|
+
import { createValidatorDirective } from '@cedarjs/graphql-server'
|
|
4
|
+
|
|
5
|
+
export const schema = gql`
|
|
6
|
+
"""
|
|
7
|
+
Use to skip authentication checks and allow public access.
|
|
8
|
+
"""
|
|
9
|
+
directive @skipAuth on FIELD_DEFINITION
|
|
10
|
+
`
|
|
11
|
+
|
|
12
|
+
const skipAuth = createValidatorDirective(schema, () => {
|
|
13
|
+
return
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
export default skipAuth
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { getDirectiveName } from '@cedarjs/testing/api'
|
|
2
|
+
|
|
3
|
+
import skipAuth from './skipAuth.js'
|
|
4
|
+
|
|
5
|
+
describe('skipAuth directive', () => {
|
|
6
|
+
it('declares the directive sdl as schema, with the correct name', () => {
|
|
7
|
+
expect(skipAuth.schema).toBeTruthy()
|
|
8
|
+
expect(getDirectiveName(skipAuth.schema)).toBe('skipAuth')
|
|
9
|
+
})
|
|
10
|
+
})
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { createGraphQLHandler } from '@cedarjs/graphql-server'
|
|
2
|
+
|
|
3
|
+
import directives from 'src/directives/**/*.{js,ts}'
|
|
4
|
+
import sdls from 'src/graphql/**/*.sdl.{js,ts}'
|
|
5
|
+
import services from 'src/services/**/*.{js,ts}'
|
|
6
|
+
|
|
7
|
+
import { db } from 'src/lib/db.js'
|
|
8
|
+
import { logger } from 'src/lib/logger.js'
|
|
9
|
+
|
|
10
|
+
export const handler = createGraphQLHandler({
|
|
11
|
+
loggerConfig: { logger, options: {} },
|
|
12
|
+
directives,
|
|
13
|
+
sdls,
|
|
14
|
+
services,
|
|
15
|
+
onException: () => {
|
|
16
|
+
// Disconnect from your database with an unhandled exception.
|
|
17
|
+
db.$disconnect()
|
|
18
|
+
},
|
|
19
|
+
})
|
|
File without changes
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Once you are ready to add authentication to your application
|
|
3
|
+
* you'll build out requireAuth() with real functionality. For
|
|
4
|
+
* now we just return `true` so that the calls in services
|
|
5
|
+
* have something to check against, simulating a logged
|
|
6
|
+
* in user that is allowed to access that service.
|
|
7
|
+
*
|
|
8
|
+
* See https://redwoodjs.com/docs/authentication for more info.
|
|
9
|
+
*/
|
|
10
|
+
export const isAuthenticated = () => {
|
|
11
|
+
return true
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const hasRole = ({ roles }) => {
|
|
15
|
+
return roles !== undefined
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// This is used by the redwood directive
|
|
19
|
+
// in ./api/src/directives/requireAuth
|
|
20
|
+
|
|
21
|
+
// Roles are passed in by the requireAuth directive if you have auth setup
|
|
22
|
+
// eslint-disable-next-line no-unused-vars
|
|
23
|
+
export const requireAuth = ({ roles }) => {
|
|
24
|
+
return isAuthenticated()
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const getCurrentUser = async () => {
|
|
28
|
+
throw new Error(
|
|
29
|
+
'Auth is not set up yet. See https://redwoodjs.com/docs/authentication ' +
|
|
30
|
+
'to get started'
|
|
31
|
+
)
|
|
32
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// See https://www.prisma.io/docs/reference/tools-and-interfaces/prisma-client/constructor
|
|
2
|
+
// for options.
|
|
3
|
+
|
|
4
|
+
import { PrismaClient } from '@prisma/client'
|
|
5
|
+
|
|
6
|
+
import { emitLogLevels, handlePrismaLogging } from '@cedarjs/api/logger'
|
|
7
|
+
|
|
8
|
+
import { logger } from './logger.js'
|
|
9
|
+
|
|
10
|
+
const prismaClient = new PrismaClient({
|
|
11
|
+
log: emitLogLevels(['info', 'warn', 'error']),
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
handlePrismaLogging({
|
|
15
|
+
db: prismaClient,
|
|
16
|
+
logger,
|
|
17
|
+
logLevels: ['info', 'warn', 'error'],
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Global Prisma client extensions should be added here, as $extend
|
|
22
|
+
* returns a new instance.
|
|
23
|
+
* export const db = prismaClient.$extend(...)
|
|
24
|
+
* Add any .$on hooks before using $extend
|
|
25
|
+
*/
|
|
26
|
+
export const db = prismaClient
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { createLogger } from '@cedarjs/api/logger'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Creates a logger with RedwoodLoggerOptions
|
|
5
|
+
*
|
|
6
|
+
* These extend and override default LoggerOptions,
|
|
7
|
+
* can define a destination like a file or other supported pino log transport stream,
|
|
8
|
+
* and sets whether or not to show the logger configuration settings (defaults to false)
|
|
9
|
+
*
|
|
10
|
+
* @param RedwoodLoggerOptions
|
|
11
|
+
*
|
|
12
|
+
* RedwoodLoggerOptions have
|
|
13
|
+
* @param {options} LoggerOptions - defines how to log, such as redaction and format
|
|
14
|
+
* @param {string | DestinationStream} destination - defines where to log, such as a transport stream or file
|
|
15
|
+
* @param {boolean} showConfig - whether to display logger configuration on initialization
|
|
16
|
+
*/
|
|
17
|
+
export const logger = createLogger({})
|
|
File without changes
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
.idea
|
|
2
|
+
.DS_Store
|
|
3
|
+
.env*
|
|
4
|
+
!.env.example
|
|
5
|
+
!.env.defaults
|
|
6
|
+
.netlify
|
|
7
|
+
.redwood/*
|
|
8
|
+
!.redwood/README.md
|
|
9
|
+
dev.db*
|
|
10
|
+
dist
|
|
11
|
+
dist-babel
|
|
12
|
+
node_modules
|
|
13
|
+
yarn-error.log
|
|
14
|
+
web/public/mockServiceWorker.js
|
|
15
|
+
web/types/graphql.d.ts
|
|
16
|
+
api/types/graphql.d.ts
|
|
17
|
+
api/src/lib/generateGraphiQLHeader.*
|
|
18
|
+
.pnp.*
|
|
19
|
+
.yarn/*
|
|
20
|
+
!.yarn/patches
|
|
21
|
+
!.yarn/plugins
|
|
22
|
+
!.yarn/releases
|
|
23
|
+
!.yarn/sdks
|
|
24
|
+
!.yarn/versions
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// This file is used by the VSCode GraphQL extension
|
|
2
|
+
|
|
3
|
+
const { getPaths } = require('@cedarjs/project-config')
|
|
4
|
+
|
|
5
|
+
/** @type {import('graphql-config').IGraphQLConfig} */
|
|
6
|
+
const config = {
|
|
7
|
+
schema: getPaths().generated.schema,
|
|
8
|
+
documents: './web/src/**/!(*.d).{ts,tsx,js,jsx}',
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
module.exports = config
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"private": true,
|
|
3
|
+
"type": "module",
|
|
4
|
+
"workspaces": {
|
|
5
|
+
"packages": [
|
|
6
|
+
"api",
|
|
7
|
+
"web"
|
|
8
|
+
]
|
|
9
|
+
},
|
|
10
|
+
"devDependencies": {
|
|
11
|
+
"@cedarjs/core": "0.0.5",
|
|
12
|
+
"@cedarjs/project-config": "0.0.5",
|
|
13
|
+
"@cedarjs/testing": "0.0.5",
|
|
14
|
+
"vitest": "3.2.4"
|
|
15
|
+
},
|
|
16
|
+
"eslintConfig": {
|
|
17
|
+
"extends": "@cedarjs/eslint-config",
|
|
18
|
+
"root": true
|
|
19
|
+
},
|
|
20
|
+
"engines": {
|
|
21
|
+
"node": "=20.x"
|
|
22
|
+
},
|
|
23
|
+
"prisma": {
|
|
24
|
+
"seed": "yarn rw exec seed"
|
|
25
|
+
},
|
|
26
|
+
"packageManager": "yarn@4.9.2",
|
|
27
|
+
"resolutions": {
|
|
28
|
+
"@storybook/react-dom-shim@npm:7.6.20": "https://verdaccio.tobbe.dev/@storybook/react-dom-shim/-/react-dom-shim-8.0.8.tgz",
|
|
29
|
+
"react-is": "19.0.0-rc-f2df5694-20240916",
|
|
30
|
+
"vite": "5.4.19"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// https://prettier.io/docs/en/options.html
|
|
2
|
+
/** @type {import('prettier').RequiredOptions} */
|
|
3
|
+
module.exports = {
|
|
4
|
+
trailingComma: 'es5',
|
|
5
|
+
bracketSpacing: true,
|
|
6
|
+
tabWidth: 2,
|
|
7
|
+
semi: false,
|
|
8
|
+
singleQuote: true,
|
|
9
|
+
arrowParens: 'always',
|
|
10
|
+
overrides: [
|
|
11
|
+
{
|
|
12
|
+
files: 'Routes.*',
|
|
13
|
+
options: {
|
|
14
|
+
printWidth: 999,
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
],
|
|
18
|
+
}
|