Convert to Community

This commit is contained in:
Degradin 2025-01-22 00:09:31 +03:00
parent 3240753daf
commit 3571564f2d
3 changed files with 8 additions and 6 deletions

6
app.js
View File

@ -2,7 +2,7 @@ require('dotenv').config();
const express = require('express'); const express = require('express');
const bodyParser = require('body-parser'); const bodyParser = require('body-parser');
const sequelize = require('./db'); const sequelize = require('./db');
const { Item } = require('./models/item'); const { CommunityItem } = require('./models/item');
const path = require('path'); const path = require('path');
const app = express(); const app = express();
@ -55,7 +55,7 @@ app.post('/add-item', async (req, res) => {
})); }));
try { try {
await Item.create({ await CommunityItem.create({
text_id, text_id,
name, name,
description, description,
@ -77,7 +77,7 @@ app.post('/add-item', async (req, res) => {
}); });
// Запуск сервера // Запуск сервера
const PORT = process.env.PORT || 3000; const PORT = process.env.PORT || 3002;
app.listen(PORT, () => { app.listen(PORT, () => {
console.log(`Server is running on http://localhost:${PORT}`); console.log(`Server is running on http://localhost:${PORT}`);
}); });

View File

@ -1,7 +1,7 @@
const { DataTypes } = require('sequelize'); const { DataTypes } = require('sequelize');
const sequelize = require('../db'); const sequelize = require('../db');
const Item = sequelize.define('item', { const CommunityItem = sequelize.define('community-item', {
id: { id: {
type: DataTypes.INTEGER, type: DataTypes.INTEGER,
autoIncrement: true, autoIncrement: true,
@ -47,7 +47,7 @@ const Item = sequelize.define('item', {
img: { img: {
type: DataTypes.STRING, type: DataTypes.STRING,
allowNull: true, allowNull: true,
defaultValue: 'https://via.placeholder.com/150', defaultValue: 'template.png',
}, },
createdAt: { createdAt: {
type: DataTypes.DATE, type: DataTypes.DATE,
@ -61,4 +61,4 @@ const Item = sequelize.define('item', {
}, },
}); });
module.exports = { Item }; module.exports = { CommunityItem };

2
run.bat Normal file
View File

@ -0,0 +1,2 @@
nodemon --ignore json/ .\app.js
pause