Use seed instead of signup page for admin + basic local file uploading using TUS & Uppy
This commit is contained in:
@ -4,9 +4,11 @@
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@redwoodjs/api": "7.7.4",
|
||||
"@redwoodjs/api-server": "7.7.4",
|
||||
"@redwoodjs/auth-dbauth-api": "7.7.4",
|
||||
"@redwoodjs/graphql-server": "7.7.4",
|
||||
"graphql-scalars": "^1.23.0",
|
||||
"@tus/file-store": "^1.4.0",
|
||||
"@tus/server": "^1.7.0",
|
||||
"nodemailer": "^6.9.14"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
@ -1,10 +1,3 @@
|
||||
import {
|
||||
CuidDefinition,
|
||||
CuidResolver,
|
||||
EmailAddressTypeDefinition,
|
||||
EmailAddressResolver,
|
||||
} from 'graphql-scalars'
|
||||
|
||||
import { createAuthDecoder } from '@redwoodjs/auth-dbauth-api'
|
||||
import { createGraphQLHandler } from '@redwoodjs/graphql-server'
|
||||
|
||||
@ -25,13 +18,6 @@ export const handler = createGraphQLHandler({
|
||||
directives,
|
||||
sdls,
|
||||
services,
|
||||
schemaOptions: {
|
||||
typeDefs: [CuidDefinition, EmailAddressTypeDefinition],
|
||||
resolvers: {
|
||||
Cuid: CuidResolver,
|
||||
EmailAddress: EmailAddressResolver,
|
||||
},
|
||||
},
|
||||
onException: () => {
|
||||
// Disconnect from your database with an unhandled exception.
|
||||
db.$disconnect()
|
||||
|
@ -1,4 +0,0 @@
|
||||
export const schema = gql`
|
||||
scalar Cuid
|
||||
scalar EmailAddress
|
||||
`
|
@ -1,15 +0,0 @@
|
||||
export const schema = gql`
|
||||
type User {
|
||||
id: Int!
|
||||
username: String!
|
||||
email: EmailAddress!
|
||||
hashedPassword: String!
|
||||
salt: String!
|
||||
resetToken: String
|
||||
resetTokenExpiresAt: DateTime
|
||||
}
|
||||
|
||||
type Query {
|
||||
userCount: Int! @skipAuth
|
||||
}
|
||||
`
|
@ -33,7 +33,7 @@ export function censorEmail(email: string): string {
|
||||
const firstChar = localPart[0]
|
||||
const lastChar = localPart[localPart.length - 1]
|
||||
const middleLength = Math.min(localPart.length - 2, 7)
|
||||
const middle = '∗'.repeat(middleLength)
|
||||
const middle = '#'.repeat(middleLength)
|
||||
|
||||
return `${firstChar}${middle}${lastChar}@${domain}`
|
||||
}
|
||||
|
33
api/src/server.ts
Normal file
33
api/src/server.ts
Normal file
@ -0,0 +1,33 @@
|
||||
import { FileStore } from '@tus/file-store'
|
||||
import { Server } from '@tus/server'
|
||||
|
||||
import { createServer } from '@redwoodjs/api-server'
|
||||
|
||||
import { logger } from 'src/lib/logger'
|
||||
;(async () => {
|
||||
const server = await createServer({
|
||||
logger,
|
||||
})
|
||||
|
||||
const tusServer = new Server({
|
||||
path: '/files',
|
||||
datastore: new FileStore({ directory: './files' }),
|
||||
})
|
||||
|
||||
server.addContentTypeParser(
|
||||
'application/offset+octet-stream',
|
||||
(_request, _payload, done) => done(null)
|
||||
)
|
||||
|
||||
server.all('/files', (req, res) => {
|
||||
tusServer.handle(req.raw, res.raw)
|
||||
return res
|
||||
})
|
||||
|
||||
server.all('/files/*', (req, res) => {
|
||||
tusServer.handle(req.raw, res.raw)
|
||||
return res
|
||||
})
|
||||
|
||||
await server.start()
|
||||
})()
|
@ -1,7 +0,0 @@
|
||||
import type { QueryResolvers } from 'types/graphql'
|
||||
|
||||
import { db } from 'src/lib/db'
|
||||
|
||||
export const userCount: QueryResolvers['userCount'] = () => {
|
||||
return db.user.count()
|
||||
}
|
Reference in New Issue
Block a user