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

Test ts-to-js #73

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion .env.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ DATABASE_URL=file:./dev.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:
# trace | info | debug | warn | error | silent
# LOG_LEVEL=debug
# LOG_LEVEL=debug
5 changes: 3 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# DATABASE_URL=file:./dev.db
# BINARY_TARGET=native
# LOG_LEVEL=debug
# TEST_DATABASE_URL=file:./.redwood/test.db
# PRISMA_HIDE_UPDATE_MESSAGE=true
# LOG_LEVEL=trace
3 changes: 1 addition & 2 deletions .github/renovate.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

{
"extends": [
"config:base"
Expand Down Expand Up @@ -31,4 +30,4 @@
"react",
"react-dom"
]
}
}
8 changes: 1 addition & 7 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,11 @@ 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
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
7 changes: 5 additions & 2 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
"wix.vscode-import-cost",
"pflannery.vscode-versionlens",
"editorconfig.editorconfig",
"prisma.prisma"
"prisma.prisma",
"graphql.vscode-graphql",
"csstools.postcss",
"bradlc.vscode-tailwindcss"
],
"unwantedRecommendations": []
}
}
36 changes: 26 additions & 10 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,38 @@
{
"version": "0.2.0",
"version": "0.3.0",
"configurations": [
{
"command": "yarn redwood dev",
"name": "launch development",
"command": "yarn redwood dev --apiDebugPort 18911",
"name": "Run Dev Server",
"request": "launch",
"type": "node-terminal"
},
{
"type": "pwa-node",
"request": "launch",
"name": "launch api",
"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>/**"
],
"cwd": "${workspaceFolder}/api",
"envFile": "${workspaceFolder}/.env.defaults",
"program": "${workspaceFolder}/node_modules/.bin/dev-server"
}
"type": "node",
"protocol": "inspector",
"stopOnEntry": false,
"localRoot": "${workspaceFolder}/node_modules/@redwoodjs/api-server/dist",
"remoteRoot": "${workspaceFolder}/node_modules/@redwoodjs/api-server/dist",
"sourceMaps": true,
"restart": true
},
{
"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"
},
]
}
786 changes: 0 additions & 786 deletions .yarn/releases/yarn-3.2.1.cjs

This file was deleted.

783 changes: 783 additions & 0 deletions .yarn/releases/yarn-3.2.3.cjs

Large diffs are not rendered by default.

10 changes: 9 additions & 1 deletion .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
# 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

yarnPath: .yarn/releases/yarn-3.2.1.cjs
yarnPath: .yarn/releases/yarn-3.2.3.cjs
21 changes: 0 additions & 21 deletions LICENSE

This file was deleted.

4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Redwood Tutorial App

This repo represents the final state of the app created during the [Redwood Tutorial](https://redwoodjs.com/tutorial).
This repo represents the state of the app at the interval created during the [Redwood Tutorial](https://redwoodjs.com/tutorial).
It is meant to be a starting point for those working on the second half of the Tutorial, starting at the [Intermission](https://redwoodjs.com/docs/tutorial/intermission).

This repo contains much more styling than the one we built together in the tutorial, but is functionally identical.
Expand All @@ -13,6 +13,8 @@ The [tutorial itself](https://redwoodjs.com/docs/tutorial/chapter1/prerequisites
git clone https://github.com/redwoodjs/redwood-tutorial
cd redwood-tutorial
yarn install
yarn rw ts-to-js # if you wish to continue using JavaScript
yarn rw prisma migrate dev
yarn rw g secret
yarn rw dev
```
13 changes: 0 additions & 13 deletions api/db/migrations/20220208231150_create_user/migration.sql

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,17 @@ CREATE TABLE "Contact" (
"message" TEXT NOT NULL,
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
);

-- CreateTable
CREATE TABLE "User" (
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"name" TEXT,
"email" TEXT NOT NULL,
"hashedPassword" TEXT NOT NULL,
"salt" TEXT NOT NULL,
"resetToken" TEXT,
"resetTokenExpiresAt" DATETIME
);

-- CreateIndex
CREATE UNIQUE INDEX "User_email_key" ON "User"("email");
4 changes: 2 additions & 2 deletions api/db/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ model Contact {
}

model User {
id Int @id @default(autoincrement())
id Int @id @default(autoincrement())
name String?
email String @unique
email String @unique
hashedPassword String
salt String
resetToken String?
Expand Down
33 changes: 29 additions & 4 deletions api/jsconfig.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,34 @@
{
"compilerOptions": {
"baseUrl": ".",
"noEmit": true,
"allowJs": true,
"esModuleInterop": true,
"target": "esnext",
"module": "esnext",
"moduleResolution": "node",
"baseUrl": "./",
"rootDirs": [
"./src",
"../.redwood/types/mirror/api/src"
],
"paths": {
"src/*": ["./src/*"]
}
"src/*": [
"./src/*",
"../.redwood/types/mirror/api/src/*"
],
"types/*": ["./types/*", "../types/*"],
"@redwoodjs/testing": ["../node_modules/@redwoodjs/testing/api"]
},
"typeRoots": [
"../node_modules/@types",
"./node_modules/@types"
],
"types": ["jest"],
},
"include": ["src/**/*", "../.redwood/index.d.ts"]
"include": [
"src",
"../.redwood/types/includes/all-*",
"../.redwood/types/includes/api-*",
"../types"
]
}
52 changes: 52 additions & 0 deletions api/server.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/**
* This file allows you to configure the Fastify Server settings
* used by the RedwoodJS dev server.
*
* It also applies when running RedwoodJS with `yarn rw serve`.
*
* For the Fastify server options that you can set, see:
* https://www.fastify.io/docs/latest/Reference/Server/#factory
*
* Examples include: logger settings, timeouts, maximum payload limits, and more.
*
* Note: This configuration does not apply in a serverless deploy.
*/

/** @type {import('fastify').FastifyServerOptions} */
const config = {
requestTimeout: 15_000,
logger: {
// Note: If running locally using `yarn rw serve` you may want to adust
// the default non-development level to `info`
level: process.env.NODE_ENV === 'development' ? 'debug' : 'warn',
},
}

/**
* You can also register Fastify plugins and additional routes for the API and Web sides
* in the configureFastify function.
*
* This function has access to the Fastify instance and options, such as the side
* (web, api, or proxy) that is being configured and other settings like the apiRootPath
* of the functions endpoint.
*
* Note: This configuration does not apply in a serverless deploy.
*/

/** @type {import('@redwoodjs/api-server/dist/fastify').FastifySideConfigFn} */
const configureFastify = async (fastify, options) => {
if (options.side === 'api') {
fastify.log.info({ custom: { options } }, 'Configuring api side')
}

if (options.side === 'web') {
fastify.log.info({ custom: { options } }, 'Configuring web side')
}

return fastify
}

module.exports = {
config,
configureFastify,
}
3 changes: 1 addition & 2 deletions api/src/directives/requireAuth/requireAuth.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ export const schema = gql`

const validate = ({ directiveArgs }) => {
const { roles } = directiveArgs

applicationRequireAuth({ roles: roles })
applicationRequireAuth({ roles })
}

const requireAuth = createValidatorDirective(schema, validate)
Expand Down
2 changes: 1 addition & 1 deletion api/src/directives/requireAuth/requireAuth.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('requireAuth directive', () => {
// 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: { currentUser: { id: 1, name: 'Bob McBobFace' } },
context: { currentUser: { id: 1, email: '[email protected]' } },
})

expect(mockExecution).not.toThrowError()
Expand Down
Loading