added some base code to start doing work
This commit is contained in:
@@ -0,0 +1,2 @@
|
|||||||
|
node_modules
|
||||||
|
package-lock.json
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
const express = require('express')
|
||||||
|
const path = require('path')
|
||||||
|
|
||||||
|
const authRoutes = require('./routes/auth')
|
||||||
|
const productsRoutes = require('./routes/products')
|
||||||
|
const usersRoutes = require('./routes/users')
|
||||||
|
|
||||||
|
const app = express()
|
||||||
|
const port = process.env.PORT || 3000
|
||||||
|
|
||||||
|
// Middleware
|
||||||
|
app.use(express.json()) // For parsing application/json
|
||||||
|
app.use(express.urlencoded({ extended: true })) // For parsing URL-encoded form data
|
||||||
|
|
||||||
|
// Static Files (Serving Frontend)
|
||||||
|
app.use(express.static(path.join(__dirname, 'public')))
|
||||||
|
|
||||||
|
// Mount Routes
|
||||||
|
app.use('/auth', authRoutes)
|
||||||
|
app.use('/products', productsRoutes)
|
||||||
|
app.use('/users', usersRoutes)
|
||||||
|
|
||||||
|
// Default Route (Catch-all for undefined routes)
|
||||||
|
app.use((req, res, next) => {
|
||||||
|
res.status(404).send('Sorry, the resource you requested could not be found.')
|
||||||
|
})
|
||||||
|
|
||||||
|
app.listen(port, () => {
|
||||||
|
console.log(`Server listening on port ${port}`)
|
||||||
|
})
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
// config/index.js
|
||||||
|
export default {
|
||||||
|
database: {
|
||||||
|
host: process.env.DB_HOST || 'localhost',
|
||||||
|
user: process.env.DB_USER || 'your_db_user',
|
||||||
|
password: process.env.DB_PASSWORD || 'your_db_password',
|
||||||
|
database: process.env.DB_NAME || 'your_db_name',
|
||||||
|
port: process.env.DB_PORT || 5432,
|
||||||
|
},
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
// eslint.config.js (Advanced alternative)
|
||||||
|
import prettierPlugin from 'eslint-plugin-prettier'
|
||||||
|
import prettierConfig from 'eslint-config-prettier'
|
||||||
|
import prettierOptions from './prettier.config.js' // Import your config directly
|
||||||
|
import importPlugin from 'eslint-plugin-import'
|
||||||
|
|
||||||
|
export default [
|
||||||
|
{
|
||||||
|
plugins: {
|
||||||
|
prettier: prettierPlugin,
|
||||||
|
import: importPlugin,
|
||||||
|
},
|
||||||
|
rules: {
|
||||||
|
...prettierConfig.rules,
|
||||||
|
'prettier/prettier': ['error', prettierOptions],
|
||||||
|
'no-sequences': 'off',
|
||||||
|
'no-console': 'warn',
|
||||||
|
'import/first': 'error',
|
||||||
|
'import/newline-after-import': 'error',
|
||||||
|
'import/no-duplicates': 'error',
|
||||||
|
'import/no-unresolved': 'error',
|
||||||
|
'import/no-unused-modules': ['warn', { missingExports: true }],
|
||||||
|
quotes: ['error', 'single'],
|
||||||
|
semi: 'off',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]
|
||||||
+15
-6
@@ -1,12 +1,16 @@
|
|||||||
{
|
{
|
||||||
"name": "express-postgres-example",
|
"name": "tcg-collectors-server",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"description": "A basic Express application with PostgreSQL integration.",
|
"description": "A basic Express application with PostgreSQL integration.",
|
||||||
"main": "app.js",
|
"main": "app.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "node app.js",
|
"start": "node app.js",
|
||||||
"dev": "nodemon app.js"
|
"dev": "nodemon app.js",
|
||||||
|
"lint": "eslint .",
|
||||||
|
"lint:fix": "eslint . --fix",
|
||||||
|
"format": "prettier --config prettier.config.js --write ."
|
||||||
},
|
},
|
||||||
|
"type": "module",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"express",
|
"express",
|
||||||
"node.js",
|
"node.js",
|
||||||
@@ -17,12 +21,17 @@
|
|||||||
"author": "Your Name",
|
"author": "Your Name",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"express": "^4.18.2",
|
|
||||||
"pg": "^8.8.0",
|
|
||||||
"dotenv": "^16.0.3",
|
"dotenv": "^16.0.3",
|
||||||
"nodemon": "^3.0.0"
|
"express": "^4.18.2",
|
||||||
|
"pg": "^8.8.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"jest": "^29.0.0"
|
"eslint": "^10.3.0",
|
||||||
|
"eslint-config-prettier": "^10.1.8",
|
||||||
|
"eslint-plugin-import": "^2.32.0",
|
||||||
|
"eslint-plugin-prettier": "^5.5.5",
|
||||||
|
"jest": "^29.0.0",
|
||||||
|
"nodemon": "^3.0.0",
|
||||||
|
"prettier": "^3.8.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
// prettier.config.js
|
||||||
|
export default {
|
||||||
|
trailingComma: 'es5',
|
||||||
|
tabWidth: 2,
|
||||||
|
semi: false, // Crucial: Sets semicolon removal.
|
||||||
|
useTabs: true,
|
||||||
|
singleQuote: true,
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user