forked from PolarisPyra/artemisapi
Compare commits
No commits in common. "main" and "develop" have entirely different histories.
268
.gitignore
vendored
Executable file → Normal file
268
.gitignore
vendored
Executable file → Normal file
|
@ -1,135 +1,135 @@
|
|||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
lerna-debug.log*
|
||||
.pnpm-debug.log*
|
||||
|
||||
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
*.pid.lock
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
lib-cov
|
||||
/.vscode/
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
*.lcov
|
||||
|
||||
# nyc test coverage
|
||||
.nyc_output
|
||||
|
||||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||
.grunt
|
||||
|
||||
# Bower dependency directory (https://bower.io/)
|
||||
bower_components
|
||||
|
||||
# node-waf configuration
|
||||
.lock-wscript
|
||||
|
||||
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||
build/Release
|
||||
|
||||
# Dependency directories
|
||||
node_modules/
|
||||
jspm_packages/
|
||||
|
||||
# Snowpack dependency directory (https://snowpack.dev/)
|
||||
web_modules/
|
||||
|
||||
# TypeScript cache
|
||||
*.tsbuildinfo
|
||||
|
||||
# Optional npm cache directory
|
||||
.npm
|
||||
|
||||
# Optional eslint cache
|
||||
.eslintcache
|
||||
|
||||
# Optional stylelint cache
|
||||
.stylelintcache
|
||||
|
||||
# Microbundle cache
|
||||
.rpt2_cache/
|
||||
.rts2_cache_cjs/
|
||||
.rts2_cache_es/
|
||||
.rts2_cache_umd/
|
||||
|
||||
# Optional REPL history
|
||||
.node_repl_history
|
||||
|
||||
# Output of 'npm pack'
|
||||
*.tgz
|
||||
|
||||
# Yarn Integrity file
|
||||
.yarn-integrity
|
||||
|
||||
# dotenv environment variable files
|
||||
.env
|
||||
.env.development.local
|
||||
.env.development
|
||||
.env.production
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
.env.local
|
||||
production.env
|
||||
development.env
|
||||
|
||||
# parcel-bundler cache (https://parceljs.org/)
|
||||
.cache
|
||||
.parcel-cache
|
||||
|
||||
# Next.js build output
|
||||
.next
|
||||
out
|
||||
|
||||
# Nuxt.js build / generate output
|
||||
.nuxt
|
||||
dist
|
||||
|
||||
# Gatsby files
|
||||
.cache/
|
||||
# Comment in the public line in if your project uses Gatsby and not Next.js
|
||||
# https://nextjs.org/blog/next-9-1#public-directory-support
|
||||
# public
|
||||
|
||||
# vuepress build output
|
||||
.vuepress/dist
|
||||
|
||||
# vuepress v2.x temp and cache directory
|
||||
.temp
|
||||
.cache
|
||||
|
||||
# Docusaurus cache and generated files
|
||||
.docusaurus
|
||||
|
||||
# Serverless directories
|
||||
.serverless/
|
||||
|
||||
# FuseBox cache
|
||||
.fusebox/
|
||||
|
||||
# DynamoDB Local files
|
||||
.dynamodb/
|
||||
|
||||
# TernJS port file
|
||||
.tern-port
|
||||
|
||||
# Stores VSCode versions used for testing VSCode extensions
|
||||
.vscode-test
|
||||
|
||||
# yarn v2
|
||||
.yarn/cache
|
||||
.yarn/unplugged
|
||||
.yarn/build-state.yml
|
||||
.yarn/install-state.gz
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
lerna-debug.log*
|
||||
.pnpm-debug.log*
|
||||
|
||||
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
*.pid.lock
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
lib-cov
|
||||
/.vscode/
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
*.lcov
|
||||
|
||||
# nyc test coverage
|
||||
.nyc_output
|
||||
|
||||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||
.grunt
|
||||
|
||||
# Bower dependency directory (https://bower.io/)
|
||||
bower_components
|
||||
|
||||
# node-waf configuration
|
||||
.lock-wscript
|
||||
|
||||
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||
build/Release
|
||||
|
||||
# Dependency directories
|
||||
node_modules/
|
||||
jspm_packages/
|
||||
|
||||
# Snowpack dependency directory (https://snowpack.dev/)
|
||||
web_modules/
|
||||
|
||||
# TypeScript cache
|
||||
*.tsbuildinfo
|
||||
|
||||
# Optional npm cache directory
|
||||
.npm
|
||||
|
||||
# Optional eslint cache
|
||||
.eslintcache
|
||||
|
||||
# Optional stylelint cache
|
||||
.stylelintcache
|
||||
|
||||
# Microbundle cache
|
||||
.rpt2_cache/
|
||||
.rts2_cache_cjs/
|
||||
.rts2_cache_es/
|
||||
.rts2_cache_umd/
|
||||
|
||||
# Optional REPL history
|
||||
.node_repl_history
|
||||
|
||||
# Output of 'npm pack'
|
||||
*.tgz
|
||||
|
||||
# Yarn Integrity file
|
||||
.yarn-integrity
|
||||
|
||||
# dotenv environment variable files
|
||||
.env
|
||||
.env.development.local
|
||||
.env.development
|
||||
.env.production
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
.env.local
|
||||
production.env
|
||||
development.env
|
||||
|
||||
# parcel-bundler cache (https://parceljs.org/)
|
||||
.cache
|
||||
.parcel-cache
|
||||
|
||||
# Next.js build output
|
||||
.next
|
||||
out
|
||||
|
||||
# Nuxt.js build / generate output
|
||||
.nuxt
|
||||
dist
|
||||
|
||||
# Gatsby files
|
||||
.cache/
|
||||
# Comment in the public line in if your project uses Gatsby and not Next.js
|
||||
# https://nextjs.org/blog/next-9-1#public-directory-support
|
||||
# public
|
||||
|
||||
# vuepress build output
|
||||
.vuepress/dist
|
||||
|
||||
# vuepress v2.x temp and cache directory
|
||||
.temp
|
||||
.cache
|
||||
|
||||
# Docusaurus cache and generated files
|
||||
.docusaurus
|
||||
|
||||
# Serverless directories
|
||||
.serverless/
|
||||
|
||||
# FuseBox cache
|
||||
.fusebox/
|
||||
|
||||
# DynamoDB Local files
|
||||
.dynamodb/
|
||||
|
||||
# TernJS port file
|
||||
.tern-port
|
||||
|
||||
# Stores VSCode versions used for testing VSCode extensions
|
||||
.vscode-test
|
||||
|
||||
# yarn v2
|
||||
.yarn/cache
|
||||
.yarn/unplugged
|
||||
.yarn/build-state.yml
|
||||
.yarn/install-state.gz
|
||||
.pnp.*
|
75
app.js
Executable file → Normal file
75
app.js
Executable file → Normal file
|
@ -1,73 +1,18 @@
|
|||
const express = require("express");
|
||||
const cors = require("cors");
|
||||
const helmet = require("helmet");
|
||||
const expressSession = require("express-session");
|
||||
const MySQLStore = require("express-mysql-session")(expressSession);
|
||||
|
||||
const express = require('express');
|
||||
const app = express();
|
||||
const nodeEnv = process.env.NODE_ENV;
|
||||
|
||||
if (!nodeEnv) {
|
||||
console.error("No NODE_ENV specified in environment. Terminating.");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// Let NGINX do its magic.
|
||||
app.set("trust proxy", "loopback");
|
||||
app.set("query parser", "simple");
|
||||
|
||||
const store = new MySQLStore({
|
||||
host: process.env.host,
|
||||
user: process.env.user,
|
||||
password: process.env.password,
|
||||
database: process.env.database,
|
||||
port: process.env.port,
|
||||
schema: {
|
||||
tableName: "cozynet_artemisapi_sessions",
|
||||
columnNames: {
|
||||
session_id: "session_id",
|
||||
expires: "expires",
|
||||
data: "data",
|
||||
},
|
||||
},
|
||||
});
|
||||
const userSessionMiddleware = expressSession({
|
||||
name: "ArtemisAPI_SESSION",
|
||||
secret: process.env.JWT_SECRET,
|
||||
store,
|
||||
resave: true,
|
||||
saveUninitialized: false,
|
||||
cookie: {
|
||||
secure: nodeEnv === "production",
|
||||
sameSite: nodeEnv === "production" ? "strict" : "none",
|
||||
},
|
||||
});
|
||||
|
||||
if (nodeEnv !== "production" && process.env.CLIENT_DEV_SERVER && process.env.CLIENT_DEV_SERVER.length > 0) {
|
||||
const clientDevServer = process.env.CLIENT_DEV_SERVER;
|
||||
|
||||
app.use(cors({ credentials: true, origin: clientDevServer }));
|
||||
} else {
|
||||
app.use(cors({ credentials: false, origin: "*" }));
|
||||
app.use((req, res, next) => {
|
||||
res.header("Access-Control-Allow-Credentials", "false");
|
||||
next();
|
||||
});
|
||||
app.use(helmet());
|
||||
}
|
||||
|
||||
app.use(userSessionMiddleware);
|
||||
|
||||
const sunGetRoutes = require("./chunithm/13/getRoutes");
|
||||
const sunPostRoutes = require("./chunithm/13/postRoutes");
|
||||
const cors = require("cors");
|
||||
|
||||
const sunGetRoutes = require('./chunithm/13/getRoutes');
|
||||
const sunPostRoutes = require('./chunithm/13/postRoutes');
|
||||
const sunDeleteRoutes = require('./chunithm/13/deleteRoutes');
|
||||
app.use(express.json());
|
||||
// app.use(cors({ credentials: true, origin: "*" }));
|
||||
app.use("/SDHD", sunGetRoutes);
|
||||
app.use("/SDHD", sunPostRoutes);
|
||||
app.use(cors({ credentials: true, origin: '*' }));
|
||||
app.use('/SDHD', sunGetRoutes);
|
||||
app.use('/SDHD', sunPostRoutes);
|
||||
app.use('/SDHD', sunDeleteRoutes);
|
||||
|
||||
// Starting the server
|
||||
const PORT = 4000;
|
||||
app.listen(PORT, () => {
|
||||
console.log(`Server is running on http://localhost:${PORT}`);
|
||||
});
|
||||
});
|
37
chunithm/13/deleteRoutes.js
Normal file
37
chunithm/13/deleteRoutes.js
Normal file
|
@ -0,0 +1,37 @@
|
|||
|
||||
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const pool1 = require('../../db');
|
||||
|
||||
router.delete("/remove-favorite-song", removeFavoriteSongHandler);
|
||||
|
||||
|
||||
function removeFavoriteSongHandler(req, res) {
|
||||
const user = req.query.user;
|
||||
const songId = req.query.songId;
|
||||
const version = req.query.version;
|
||||
const favKind = req.query.favKind;
|
||||
|
||||
if (!user || !songId || !version || !favKind) {
|
||||
return res.status(400).json({ error: "User, songId, version, and favKind parameters are required" });
|
||||
}
|
||||
|
||||
pool1.query(
|
||||
`
|
||||
DELETE FROM chuni_item_favorite
|
||||
WHERE user = ? AND favId = ? AND version = ? AND favKind = ?
|
||||
`,
|
||||
[user, songId, version, favKind],
|
||||
(error, results) => {
|
||||
if (error) {
|
||||
console.error("Error removing favorite song:", error);
|
||||
return res.status(500).json({ error: "Error removing favorite song" });
|
||||
}
|
||||
|
||||
res.json({ message: "Favorite song removed successfully" });
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
module.exports = router;
|
1333
chunithm/13/getRoutes.js
Executable file → Normal file
1333
chunithm/13/getRoutes.js
Executable file → Normal file
File diff suppressed because it is too large
Load Diff
1780
chunithm/13/postRoutes.js
Executable file → Normal file
1780
chunithm/13/postRoutes.js
Executable file → Normal file
File diff suppressed because it is too large
Load Diff
28
db.js
Executable file → Normal file
28
db.js
Executable file → Normal file
|
@ -1,14 +1,14 @@
|
|||
const mysql = require("mysql2");
|
||||
const dbUsername = process.env.user;
|
||||
const dbPassword = process.env.password;
|
||||
const dbHost = process.env.host;
|
||||
const dbDatabase = process.env.database;
|
||||
const pool = mysql.createPool({
|
||||
host: dbHost,
|
||||
user: dbUsername,
|
||||
password: dbPassword,
|
||||
database: dbDatabase,
|
||||
port: process.env.port,
|
||||
});
|
||||
|
||||
module.exports = pool;
|
||||
const mysql = require("mysql2");
|
||||
const dbUsername = process.env.user;
|
||||
const dbPassword = process.env.password;
|
||||
const dbHost = process.env.host;
|
||||
const dbDatabase = process.env.database;
|
||||
const pool = mysql.createPool({
|
||||
host: dbHost,
|
||||
user: dbUsername,
|
||||
password: dbPassword,
|
||||
database: dbDatabase,
|
||||
port: process.env.port,
|
||||
});
|
||||
|
||||
module.exports = pool;
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
const RequireNotGuest = (req, res, next) => {
|
||||
if (req.session.cozynet?.userId === undefined) {
|
||||
return res.status(401).json({
|
||||
success: false,
|
||||
message: "This endpoint requires authentication.",
|
||||
})
|
||||
}
|
||||
|
||||
next();
|
||||
}
|
||||
|
||||
module.exports = { RequireNotGuest };
|
0
package-lock.json
generated
Executable file → Normal file
0
package-lock.json
generated
Executable file → Normal file
7
package.json
Executable file → Normal file
7
package.json
Executable file → Normal file
|
@ -5,8 +5,8 @@
|
|||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"start:dev": "nodemon -r dotenv/config app.js dotenv_config_path=.env.development",
|
||||
"start:prod": "nodemon -r dotenv/config app.js dotenv_config_path=.env.production"
|
||||
"start:dev": "nodemon --env-file=.env.development app.js",
|
||||
"start:prod": "nodemon --env-file=.env.production app.js"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
|
@ -19,14 +19,11 @@
|
|||
"dotenv": "^16.3.1",
|
||||
"express": "^4.18.2",
|
||||
"express-jwt": "^8.4.1",
|
||||
"express-mysql-session": "^3.0.0",
|
||||
"express-session": "^1.17.3",
|
||||
"find-config": "^1.0.0",
|
||||
"fs": "^0.0.1-security",
|
||||
"helmet": "^7.1.0",
|
||||
"jsonwebtoken": "^9.0.2",
|
||||
"mysql2": "^3.6.3",
|
||||
"nodemon": "^3.1.0",
|
||||
"promisify": "^0.0.3",
|
||||
"util": "^0.12.5"
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user