experiment with new approach

This commit is contained in:
Matt Hill
2026-03-12 12:27:34 -06:00
parent 98b429fcad
commit 082254575b
511 changed files with 44511 additions and 0 deletions

15
site/server/src/environment.d.ts vendored Normal file
View File

@@ -0,0 +1,15 @@
export {}
// Here we declare the members of the process.env object, so that we
// can use them in our application code in a type-safe manner.
declare global {
namespace NodeJS {
interface ProcessEnv {
APP_ENV: string
PORT: string
COOKIE_SECRET: string
SUPERADMIN_USERNAME: string
SUPERADMIN_PASSWORD: string
}
}
}

508
site/server/src/gql/graphql-env.d.ts vendored Normal file

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,15 @@
import type { introspection } from './graphql-env.d.ts'
import { initGraphQLTada } from 'gql.tada'
export const graphql = initGraphQLTada<{
disableMasking: true
introspection: introspection
scalars: {
DateTime: string
JSON: any
Money: number
}
}>()
export type { FragmentOf, ResultOf, VariablesOf } from 'gql.tada'
export { readFragment } from 'gql.tada'

View File

@@ -0,0 +1,8 @@
import { bootstrapWorker } from '@vendure/core'
import { config } from './vendure-config'
bootstrapWorker(config)
.then(worker => worker.startJobQueue())
.catch(err => {
console.log(err)
})

8
site/server/src/index.ts Normal file
View File

@@ -0,0 +1,8 @@
import { bootstrap, runMigrations } from '@vendure/core'
import { config } from './vendure-config'
runMigrations(config)
.then(() => bootstrap(config))
.catch(err => {
console.log(err)
})

View File

@@ -0,0 +1,101 @@
import {
dummyPaymentHandler,
DefaultJobQueuePlugin,
DefaultSchedulerPlugin,
DefaultSearchPlugin,
VendureConfig,
} from '@vendure/core'
import {
defaultEmailHandlers,
EmailPlugin,
FileBasedTemplateLoader,
} from '@vendure/email-plugin'
import { AssetServerPlugin } from '@vendure/asset-server-plugin'
import { DashboardPlugin } from '@vendure/dashboard/plugin'
import { GraphiqlPlugin } from '@vendure/graphiql-plugin'
import 'dotenv/config'
import path from 'path'
const IS_DEV = process.env.APP_ENV === 'dev'
const serverPort = +process.env.PORT || 3000
export const config: VendureConfig = {
apiOptions: {
port: serverPort,
adminApiPath: 'admin-api',
shopApiPath: 'shop-api',
trustProxy: IS_DEV ? false : 1,
// The following options are useful in development mode,
// but are best turned off for production for security
// reasons.
...(IS_DEV
? {
adminApiDebug: true,
shopApiDebug: true,
}
: {}),
},
authOptions: {
tokenMethod: ['bearer', 'cookie'],
superadminCredentials: {
identifier: process.env.SUPERADMIN_USERNAME,
password: process.env.SUPERADMIN_PASSWORD,
},
cookieOptions: {
secret: process.env.COOKIE_SECRET,
},
},
dbConnectionOptions: {
type: 'better-sqlite3',
// See the README.md "Migrations" section for an explanation of
// the `synchronize` and `migrations` options.
synchronize: false,
migrations: [path.join(__dirname, './migrations/*.+(js|ts)')],
logging: false,
database: path.join(__dirname, '../vendure.sqlite'),
},
paymentOptions: {
paymentMethodHandlers: [dummyPaymentHandler],
},
// When adding or altering custom field definitions, the database will
// need to be updated. See the "Migrations" section in README.md.
customFields: {},
plugins: [
GraphiqlPlugin.init(),
AssetServerPlugin.init({
route: 'assets',
assetUploadDir: path.join(__dirname, '../static/assets'),
// For local dev, the correct value for assetUrlPrefix should
// be guessed correctly, but for production it will usually need
// to be set manually to match your production url.
assetUrlPrefix: IS_DEV ? undefined : 'https://www.my-shop.com/assets/',
}),
DefaultSchedulerPlugin.init(),
DefaultJobQueuePlugin.init({ useDatabaseForBuffer: true }),
DefaultSearchPlugin.init({ bufferUpdates: false, indexStockStatus: true }),
EmailPlugin.init({
devMode: true,
outputPath: path.join(__dirname, '../static/email/test-emails'),
route: 'mailbox',
handlers: defaultEmailHandlers,
templateLoader: new FileBasedTemplateLoader(
path.join(__dirname, '../static/email/templates'),
),
globalTemplateVars: {
// The following variables will change depending on your storefront implementation.
// Here we are assuming a storefront running at http://localhost:8080.
fromAddress: '"example" <noreply@example.com>',
verifyEmailAddressUrl: 'http://localhost:8080/verify',
passwordResetUrl: 'http://localhost:8080/password-reset',
changeEmailAddressUrl:
'http://localhost:8080/verify-email-address-change',
},
}),
DashboardPlugin.init({
route: 'dashboard',
appDir: IS_DEV
? path.join(__dirname, '../dist/dashboard')
: path.join(__dirname, 'dashboard'),
}),
],
}