-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RSC: Add rsc-caching project fixture (#11120)
- Loading branch information
Showing
58 changed files
with
1,285 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# editorconfig.org | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
indent_size = 2 | ||
indent_style = space | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# These environment variables will be used by default if you do not create any | ||
# yourself in .env. This file should be safe to check into your version control | ||
# system. Any custom values should go in .env and .env should *not* be checked | ||
# into version control. | ||
|
||
# schema.prisma defaults | ||
DATABASE_URL=file:./dev.db | ||
|
||
# location of the test database for api service scenarios (defaults to ./.redwood/test.db if not set) | ||
# TEST_DATABASE_URL=file:./.redwood/test.db | ||
|
||
# disables Prisma CLI update notifier | ||
PRISMA_HIDE_UPDATE_MESSAGE=true | ||
|
||
# Option to override the current environment's default api-side log level | ||
# See: https://redwoodjs.com/docs/logger for level options, defaults to "trace" otherwise. | ||
# Most applications want "debug" or "info" during dev, "trace" when you have issues and "warn" in production. | ||
# Ordered by how verbose they are: trace | debug | info | warn | error | silent | ||
# LOG_LEVEL=debug |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# DATABASE_URL=file:./dev.db | ||
# TEST_DATABASE_URL=file:./.redwood/test.db | ||
# PRISMA_HIDE_UPDATE_MESSAGE=true | ||
# LOG_LEVEL=trace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
.idea | ||
.DS_Store | ||
.env* | ||
!.env.example | ||
!.env.defaults | ||
.netlify | ||
.redwood/* | ||
!.redwood/README.md | ||
dist | ||
dist-babel | ||
node_modules | ||
yarn-error.log | ||
web/public/mockServiceWorker.js | ||
web/types/graphql.d.ts | ||
api/types/graphql.d.ts | ||
api/src/lib/generateGraphiQLHeader.* | ||
.pnp.* | ||
.yarn/* | ||
!.yarn/patches | ||
!.yarn/plugins | ||
!.yarn/releases | ||
!.yarn/sdks | ||
!.yarn/versions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# To learn about this file, please see https://www.gitpod.io/docs/references/gitpod-yml | ||
|
||
image: gitpod/workspace-node-lts | ||
|
||
tasks: | ||
- init: | | ||
# Cleanup terminal | ||
printf "\033[3J\033c\033[3J" | ||
yarn install | ||
command: yarn rw build -v && yarn rw serve | ||
ports: | ||
- port: 8910 | ||
name: RedwoodJS web application | ||
onOpen: notify # because we already have [browser].open = true in redwood.toml | ||
- port: 8911 | ||
name: Serverless functions | ||
onOpen: ignore | ||
|
||
vscode: | ||
extensions: | ||
- "dbaeumer.vscode-eslint" | ||
- "mgmcdermott.vscode-language-babel" | ||
- "editorconfig.editorconfig" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# .redwood | ||
|
||
## What is this directory? | ||
|
||
Redwood uses this `.redwood` directory to store transitory data that aids in the smooth and convenient operation of your Redwood project. | ||
|
||
## Do I need to do anything with this directory? | ||
|
||
No. You shouldn't have to create, edit or delete anything in this directory in your day-to-day work with Redwood. | ||
|
||
You don't need to commit any other contents of this directory to your version control system. It's ignored by default. | ||
|
||
## What's in this directory? | ||
|
||
### Files | ||
|
||
| Name | Description | | ||
| :---------------- | :------- | | ||
| commandCache.json | This file contains mappings to assist the Redwood CLI in efficiently executing commands. | | ||
| schema.graphql | This is the GraphQL schema which has been automatically generated from your Redwood project. | | ||
| telemetry.txt | Contains a unique ID used for telemetry. This value is rotated every 24 hours to protect your project's anonymity. | | ||
| test.db | The sqlite database used when running tests. | | ||
|
||
### Directories | ||
|
||
| Name | Description | | ||
| :---------- | :------- | | ||
| locks | Stores temporary files that Redwood uses to keep track of the execution of async/background tasks between processes. | | ||
| logs | Stores log files for background tasks such as update checking. | | ||
| prebuild | Stores transpiled JavaScript that is generated as part of Redwood's build process. | | ||
| telemetry | Stores the recent telemetry that the Redwood CLI has generated. You may inspect these files to see everything Redwood is anonymously collecting. | | ||
| types | Stores the results of type generation. | | ||
| updateCheck | Stores a file which contains the results of checking for Redwood updates. | | ||
| studio | Used to store data for `rw studio` | | ||
|
||
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. | ||
|
||
### Telemetry | ||
|
||
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). | ||
|
||
### Have any questions? | ||
|
||
Feel free to reach out to us in the [RedwoodJS Community](https://community.redwoodjs.com/) forum if you have any questions. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"recommendations": [ | ||
"dbaeumer.vscode-eslint", | ||
"eamodio.gitlens", | ||
"ofhumanbondage.react-proptypes-intellisense", | ||
"mgmcdermott.vscode-language-babel", | ||
"wix.vscode-import-cost", | ||
"pflannery.vscode-versionlens", | ||
"editorconfig.editorconfig", | ||
"prisma.prisma", | ||
"graphql.vscode-graphql" | ||
], | ||
"unwantedRecommendations": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
{ | ||
"version": "0.3.0", | ||
"configurations": [ | ||
{ | ||
"command": "yarn redwood dev --apiDebugPort 18911", // you can add --fwd='--open=false' to prevent the browser from opening | ||
"name": "Run Dev Server", | ||
"request": "launch", | ||
"type": "node-terminal" | ||
}, | ||
{ | ||
"name": "Attach API debugger", | ||
"port": 18911, // you can change this port, see https://redwoodjs.com/docs/project-configuration-dev-test-build#debugger-configuration | ||
"request": "attach", | ||
"skipFiles": [ | ||
"<node_internals>/**" | ||
], | ||
"type": "node", | ||
"localRoot": "${workspaceFolder}/node_modules/@redwoodjs/api-server/dist", | ||
"remoteRoot": "${workspaceFolder}/node_modules/@redwoodjs/api-server/dist", | ||
"sourceMaps": true, | ||
"restart": true, | ||
"preLaunchTask": "WaitForDevServer", | ||
}, | ||
{ | ||
"name": "Launch Web debugger", | ||
"type": "chrome", | ||
"request": "launch", | ||
"url": "http://localhost:8910", | ||
"webRoot": "${workspaceRoot}/web/src", | ||
"preLaunchTask": "WaitForDevServer", | ||
}, | ||
{ | ||
"command": "yarn redwood test api", | ||
"name": "Test api", | ||
"request": "launch", | ||
"type": "node-terminal" | ||
}, | ||
{ | ||
"command": "yarn redwood test web", | ||
"name": "Test web", | ||
"request": "launch", | ||
"type": "node-terminal" | ||
}, | ||
], | ||
"compounds": [ | ||
{ | ||
"name": "Start Debug", | ||
"configurations": [ | ||
"Run Dev Server", | ||
"Attach API debugger", | ||
"Launch Web debugger" | ||
], | ||
"stopAll": true | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"editor.tabSize": 2, | ||
"files.trimTrailingWhitespace": true, | ||
"editor.formatOnSave": false, | ||
"editor.codeActionsOnSave": { | ||
"source.fixAll.eslint": "explicit" | ||
}, | ||
"[prisma]": { | ||
"editor.formatOnSave": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"version": "2.0.0", | ||
"tasks": [ | ||
{ | ||
"label": "WaitForDevServer", | ||
"group": "none", | ||
"type": "shell", | ||
"command": "bash", | ||
"args": [ | ||
"-c", | ||
"while ! echo -n > /dev/tcp/localhost/18911; do sleep 1; done;" | ||
], | ||
"windows": { | ||
"command": "powershell", | ||
"args": [ | ||
"-NoProfile", | ||
"-ExecutionPolicy", "Bypass", | ||
"while (-not (Test-NetConnection -ComputerName localhost -Port 18911)) { Start-Sleep -Seconds 1 };" | ||
] | ||
}, | ||
"presentation": { | ||
"reveal": "silent", | ||
"revealProblems": "onProblem", | ||
"panel": "shared", | ||
"close": true | ||
} | ||
}, | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Yarn's manifest file. You can configure yarn here. | ||
# See https://yarnpkg.com/configuration/yarnrc. | ||
|
||
# For `node_modules` (see `nodeLinker` below), this is almost always the preferred option. | ||
compressionLevel: 0 | ||
|
||
enableGlobalCache: true | ||
|
||
# Lets yarn use hardlinks inside `node_modules` to dedupe packages. | ||
# For a more pnpm-like experience, consider `hardlinks-global` where hardlinks point to a global store. | ||
nmMode: hardlinks-local | ||
|
||
# How to install Node packages. | ||
# Heads up: right now, Redwood expects this to be `node-modules`. | ||
nodeLinker: node-modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Project used for testing and visualizing caching in an RWSC app |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Don't forget to tell Prisma about your edits to this file using | ||
// `yarn rw prisma migrate dev` or `yarn rw prisma db push`. | ||
// `migrate` is like committing while `push` is for prototyping. | ||
// Read more about both here: | ||
// https://www.prisma.io/docs/orm/prisma-migrate | ||
|
||
datasource db { | ||
provider = "sqlite" | ||
url = env("DATABASE_URL") | ||
} | ||
|
||
generator client { | ||
provider = "prisma-client-js" | ||
binaryTargets = "native" | ||
} | ||
|
||
// Define your own datamodels here and run `yarn redwood prisma migrate dev` | ||
// to create migrations for them and apply to your dev DB. | ||
// TODO: Please remove the following example: | ||
model UserExample { | ||
id Int @id @default(autoincrement()) | ||
email String @unique | ||
name String? | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// More info at https://redwoodjs.com/docs/project-configuration-dev-test-build | ||
|
||
const config = { | ||
rootDir: '../', | ||
preset: '@redwoodjs/testing/config/jest/api', | ||
} | ||
|
||
module.exports = config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"name": "api", | ||
"version": "0.0.0", | ||
"private": true, | ||
"dependencies": { | ||
"@redwoodjs/api": "8.0.0-canary.1102", | ||
"@redwoodjs/graphql-server": "8.0.0-canary.1102" | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
__fixtures__/rsc-caching/api/src/directives/requireAuth/requireAuth.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { mockRedwoodDirective, getDirectiveName } from '@redwoodjs/testing/api' | ||
|
||
import requireAuth from './requireAuth' | ||
|
||
describe('requireAuth directive', () => { | ||
it('declares the directive sdl as schema, with the correct name', () => { | ||
expect(requireAuth.schema).toBeTruthy() | ||
expect(getDirectiveName(requireAuth.schema)).toBe('requireAuth') | ||
}) | ||
|
||
it('requireAuth has stub implementation. Should not throw when current user', () => { | ||
// If you want to set values in context, pass it through e.g. | ||
// mockRedwoodDirective(requireAuth, { context: { currentUser: { id: 1, name: 'Lebron McGretzky' } }}) | ||
const mockExecution = mockRedwoodDirective(requireAuth, { context: {} }) | ||
|
||
expect(mockExecution).not.toThrowError() | ||
}) | ||
}) |
25 changes: 25 additions & 0 deletions
25
__fixtures__/rsc-caching/api/src/directives/requireAuth/requireAuth.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import gql from 'graphql-tag' | ||
|
||
import type { ValidatorDirectiveFunc } from '@redwoodjs/graphql-server' | ||
import { createValidatorDirective } from '@redwoodjs/graphql-server' | ||
|
||
import { requireAuth as applicationRequireAuth } from 'src/lib/auth' | ||
|
||
export const schema = gql` | ||
""" | ||
Use to check whether or not a user is authenticated and is associated | ||
with an optional set of roles. | ||
""" | ||
directive @requireAuth(roles: [String]) on FIELD_DEFINITION | ||
` | ||
|
||
type RequireAuthValidate = ValidatorDirectiveFunc<{ roles?: string[] }> | ||
|
||
const validate: RequireAuthValidate = ({ directiveArgs }) => { | ||
const { roles } = directiveArgs | ||
applicationRequireAuth({ roles }) | ||
} | ||
|
||
const requireAuth = createValidatorDirective(schema, validate) | ||
|
||
export default requireAuth |
10 changes: 10 additions & 0 deletions
10
__fixtures__/rsc-caching/api/src/directives/skipAuth/skipAuth.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { getDirectiveName } from '@redwoodjs/testing/api' | ||
|
||
import skipAuth from './skipAuth' | ||
|
||
describe('skipAuth directive', () => { | ||
it('declares the directive sdl as schema, with the correct name', () => { | ||
expect(skipAuth.schema).toBeTruthy() | ||
expect(getDirectiveName(skipAuth.schema)).toBe('skipAuth') | ||
}) | ||
}) |
16 changes: 16 additions & 0 deletions
16
__fixtures__/rsc-caching/api/src/directives/skipAuth/skipAuth.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import gql from 'graphql-tag' | ||
|
||
import { createValidatorDirective } from '@redwoodjs/graphql-server' | ||
|
||
export const schema = gql` | ||
""" | ||
Use to skip authentication checks and allow public access. | ||
""" | ||
directive @skipAuth on FIELD_DEFINITION | ||
` | ||
|
||
const skipAuth = createValidatorDirective(schema, () => { | ||
return | ||
}) | ||
|
||
export default skipAuth |
Oops, something went wrong.