mirror of
https://github.com/Start9Labs/start9.com.git
synced 2026-03-31 20:43:43 +00:00
experiment with new approach
This commit is contained in:
15
site/server/src/environment.d.ts
vendored
Normal file
15
site/server/src/environment.d.ts
vendored
Normal 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
508
site/server/src/gql/graphql-env.d.ts
vendored
Normal file
File diff suppressed because one or more lines are too long
15
site/server/src/gql/graphql.ts
Normal file
15
site/server/src/gql/graphql.ts
Normal 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'
|
||||
8
site/server/src/index-worker.ts
Normal file
8
site/server/src/index-worker.ts
Normal 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
8
site/server/src/index.ts
Normal 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)
|
||||
})
|
||||
101
site/server/src/vendure-config.ts
Normal file
101
site/server/src/vendure-config.ts
Normal 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'),
|
||||
}),
|
||||
],
|
||||
}
|
||||
Reference in New Issue
Block a user