-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add default ddex stage keys and enforce prettier (#7098)
- Loading branch information
Showing
9 changed files
with
169 additions
and
132 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,2 @@ | ||
DDEX_SECRET='54abb93ab41afeeb99a411502ea1ee9b36ec8221cdc7c80a0ceef84c8ca95fc0' | ||
DDEX_KEY='be46e3e1cc722d2ae306f93f21f5b4f08bbd0d53' |
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 |
---|---|---|
@@ -1,18 +1,30 @@ | ||
module.exports = { | ||
root: true, | ||
env: { browser: true, es2020: true }, | ||
env: { node: true, es2020: true }, | ||
extends: [ | ||
'eslint:recommended', | ||
'plugin:@typescript-eslint/recommended', | ||
'prettier', | ||
'plugin:prettier/recommended', | ||
], | ||
ignorePatterns: ['dist', '.eslintrc.cjs'], | ||
parser: '@typescript-eslint/parser', | ||
plugins: [], | ||
plugins: ['prettier'], | ||
rules: { | ||
'@typescript-eslint/no-unsafe-call': 'off', | ||
'@typescript-eslint/no-unsafe-assignment': 'off', | ||
'@typescript-eslint/no-explicit-any': 'off', | ||
'@typescript-eslint/no-non-null-assertion': 'off', | ||
'@typescript-eslint/no-empty-function': 'off' | ||
'@typescript-eslint/no-empty-function': 'off', | ||
'prettier/prettier': ['error', { | ||
singleQuote: true, | ||
semi: false, | ||
useTabs: false, | ||
tabWidth: 2, | ||
trailingComma: 'es5', | ||
printWidth: 80, | ||
bracketSpacing: true, | ||
arrowParens: 'always', | ||
}], | ||
}, | ||
} | ||
}; |
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 @@ | ||
{ | ||
"singleQuote": true, | ||
"semi": false, | ||
"useTabs": false, | ||
"tabWidth": 2, | ||
"trailingComma": "es5", | ||
"printWidth": 80, | ||
"bracketSpacing": true, | ||
"arrowParens": "always" | ||
} |
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 |
---|---|---|
@@ -1,44 +1,51 @@ | ||
/* eslint-disable @typescript-eslint/no-unused-vars */ | ||
import express, { Express, Request, Response } from "express"; | ||
import path from "path"; | ||
import * as uploadController from "./controllers/uploadController"; | ||
import { createSdkService } from "./services/sdkService"; | ||
import { createScheduledReleaseService } from "./services/scheduledReleaseService"; | ||
import { createDbService } from "./services/dbService"; | ||
import express, { Express, Request, Response } from 'express' | ||
import path from 'path' | ||
import * as uploadController from './controllers/uploadController' | ||
import { createSdkService } from './services/sdkService' | ||
import { createScheduledReleaseService } from './services/scheduledReleaseService' | ||
import { createDbService } from './services/dbService' | ||
|
||
/* | ||
* Initialize services | ||
*/ | ||
|
||
const dbUrl = process.env.audius_db_url || 'postgres://postgres:postgres@localhost:5432/audius_discovery'; | ||
const dbService = createDbService(dbUrl); | ||
const sdkService = createSdkService(); | ||
const scheduledReleaseService = createScheduledReleaseService(sdkService.getSdk()); | ||
const dbUrl = | ||
process.env.audius_db_url || | ||
'postgres://postgres:postgres@localhost:5432/audius_discovery' | ||
const dbService = createDbService(dbUrl) | ||
const sdkService = createSdkService() | ||
const scheduledReleaseService = createScheduledReleaseService( | ||
sdkService.getSdk() | ||
) | ||
|
||
/* | ||
* Define API routes | ||
*/ | ||
|
||
const app: Express = express(); | ||
app.post('/api/upload', uploadController.postUploadXml(dbService, sdkService.getSdk())); | ||
const app: Express = express() | ||
app.post( | ||
'/api/upload', | ||
uploadController.postUploadXml(dbService, sdkService.getSdk()) | ||
) | ||
app.get('/api/health_check', (req: Request, res: Response) => { | ||
res.status(200).send('DDEX is alive!'); | ||
}); | ||
res.status(200).send('DDEX is alive!') | ||
}) | ||
|
||
/* | ||
* Routes to serve the React app as static assets at the root path | ||
* Serve the React app as static assets at the root path | ||
*/ | ||
|
||
const isProduction = process.env.NODE_ENV === 'production'; | ||
const isProduction = process.env.NODE_ENV === 'production' | ||
const buildPath = isProduction | ||
? path.join(__dirname, '..', 'public') | ||
: path.join(__dirname, '..', '..', 'ddex-frontend', 'dist'); | ||
app.use(express.static(buildPath)); | ||
app.get("/", (req: Request, res: Response) => { | ||
res.sendFile(path.join(buildPath, 'index.html')); | ||
}); | ||
: path.join(__dirname, '..', '..', 'ddex-frontend', 'dist') | ||
app.use(express.static(buildPath)) | ||
app.get('/', (req: Request, res: Response) => { | ||
res.sendFile(path.join(buildPath, 'index.html')) | ||
}) | ||
app.get('*', (req: Request, res: Response) => { | ||
res.sendFile(path.join(buildPath, 'index.html')); // Fallback for handling client-side routing | ||
}); | ||
res.sendFile(path.join(buildPath, 'index.html')) // Fallback for handling client-side routing | ||
}) | ||
|
||
export default app; | ||
export default app |
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
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 |
---|---|---|
@@ -1,9 +1,14 @@ | ||
import app from './app'; | ||
import dotenv from 'dotenv'; | ||
import dotenv from 'dotenv' | ||
import path from 'path' | ||
|
||
dotenv.config(); | ||
const port = process.env.DDEX_PORT || 8926; | ||
// Load env vars based on NODE_ENV | ||
const envFile = process.env.NODE_ENV === 'stage' ? '.env.stage' : '.env' | ||
dotenv.config({ path: path.resolve(process.cwd(), envFile) }) | ||
|
||
import app from './app' | ||
|
||
const port = process.env.DDEX_PORT || 8926 | ||
|
||
app.listen(port, () => { | ||
console.log(`[server]: Server is running at http://localhost:${port}`); | ||
}); | ||
console.log(`[server]: Server is running at http://localhost:${port}`) | ||
}) |
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 |
---|---|---|
@@ -1,9 +1,9 @@ | ||
import postgres from 'postgres'; | ||
import postgres from 'postgres' | ||
|
||
export const createDbService = (dbUrl: string) => { | ||
const sql = postgres(dbUrl); | ||
const sql = postgres(dbUrl) | ||
|
||
return { | ||
sql | ||
}; | ||
}; | ||
sql, | ||
} | ||
} |
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
Oops, something went wrong.