update,
This commit is contained in:
5
tsc1877/task1/project/.env.example
Normal file
5
tsc1877/task1/project/.env.example
Normal file
@@ -0,0 +1,5 @@
|
||||
DB_HOST=localhost
|
||||
DB_PORT=6033
|
||||
DB_NAME=app_db
|
||||
DB_USER=db_user
|
||||
DB_PASSWORD=db_user_pass
|
5
tsc1877/task1/project/.env.local.example
Normal file
5
tsc1877/task1/project/.env.local.example
Normal file
@@ -0,0 +1,5 @@
|
||||
DB_HOST=mysql
|
||||
DB_PORT=3306
|
||||
DB_NAME=app_db
|
||||
DB_USER=db_user
|
||||
DB_PASSWORD=db_user_pass
|
75
tsc1877/task1/project/README.md
Normal file
75
tsc1877/task1/project/README.md
Normal file
@@ -0,0 +1,75 @@
|
||||
# README
|
||||
|
||||
### to develop
|
||||
|
||||
```bash
|
||||
$ ./dc_up.sh
|
||||
|
||||
# inside docker prompt
|
||||
$ ./entry.sh
|
||||
```
|
||||
|
||||
### to deploy
|
||||
|
||||
```bash
|
||||
$ ./dc_kill.sh
|
||||
$ ./dc_down.sh
|
||||
$ ./dc_up.sh
|
||||
|
||||
# inside docker prompt
|
||||
$ ./entry.sh
|
||||
```
|
||||
|
||||
### pages:
|
||||
|
||||
```
|
||||
# https://secure.s34.ierg4210.ie.cuhk.edu.hk/
|
||||
|
||||
# shopfront
|
||||
http://13.50.75.106/shopfront
|
||||
|
||||
# customer login
|
||||
http://13.50.75.106/shopfront/login
|
||||
|
||||
# admin
|
||||
http://13.50.75.106/admin
|
||||
|
||||
# admin login
|
||||
http://13.50.75.106/admin/login
|
||||
```
|
||||
|
||||
### test a/c
|
||||
|
||||
#### Admin account
|
||||
|
||||
admin@vtkhmall.com
|
||||
nimda
|
||||
|
||||
#### customer 1 account
|
||||
|
||||
cust1@vtkhmall.com
|
||||
1tsuc
|
||||
|
||||
#### customer 2 account
|
||||
|
||||
cust2@vtkhmall.com
|
||||
2tsuc
|
||||
|
||||
### paypal a/c
|
||||
|
||||
i. A merchant account – Email and Password
|
||||
sb-j4nbw29912003@business.example.com
|
||||
X<LqO7Sb
|
||||
|
||||
ii. A buyer account – Email and Password
|
||||
sb-b00gb30304504@personal.example.com
|
||||
4s@0f>IE
|
||||
|
||||
b. Create a sandbox application linked to the merchant account:
|
||||
i. an application – Client ID
|
||||
https://developer.paypal.com/dashboard/accounts/edit/4829534511909691981?accountName=sb-j4nbw29912003@business.example.com
|
||||
helloworld
|
||||
Client ID
|
||||
AQT5-eAKNK7IhAhBGlbHBu_9jBx74ZLCfEioKUWQMXMuMmLcnffmpoUz_z-ewOuKZmpSlDk74UtlH58O
|
||||
Secret key 1
|
||||
EMtwOzHACol7Tx8NHOa3eV3TPu2AerZEunJ3MBZfYYcxPeUDy-TNLqqcdL0UDQsrHMpQKeCRPcjKnwNy
|
1
tsc1877/task1/project/TODO.md
Normal file
1
tsc1877/task1/project/TODO.md
Normal file
@@ -0,0 +1 @@
|
||||
search `loading<` replace <Loading />
|
37
tsc1877/task1/project/account.md
Normal file
37
tsc1877/task1/project/account.md
Normal file
@@ -0,0 +1,37 @@
|
||||
|
||||
### test a/c
|
||||
|
||||
#### proxy
|
||||
admin@123.com
|
||||
Aa1234567
|
||||
|
||||
#### Admin account
|
||||
admin@vtkhmall.com
|
||||
nimda
|
||||
|
||||
#### customer 1 account
|
||||
cust1@vtkhmall.com
|
||||
1tsuc
|
||||
|
||||
#### customer 2 account
|
||||
cust2@vtkhmall.com
|
||||
2tsuc
|
||||
|
||||
|
||||
### paypal a/c
|
||||
i. A merchant account – Email and Password
|
||||
sb-j4nbw29912003@business.example.com
|
||||
X<LqO7Sb
|
||||
|
||||
ii. A buyer account – Email and Password
|
||||
sb-b00gb30304504@personal.example.com
|
||||
4s@0f>IE
|
||||
|
||||
b. Create a sandbox application linked to the merchant account:
|
||||
i. an application – Client ID
|
||||
https://developer.paypal.com/dashboard/accounts/edit/4829534511909691981?accountName=sb-j4nbw29912003@business.example.com
|
||||
helloworld
|
||||
Client ID
|
||||
AQT5-eAKNK7IhAhBGlbHBu_9jBx74ZLCfEioKUWQMXMuMmLcnffmpoUz_z-ewOuKZmpSlDk74UtlH58O
|
||||
Secret key 1
|
||||
EMtwOzHACol7Tx8NHOa3eV3TPu2AerZEunJ3MBZfYYcxPeUDy-TNLqqcdL0UDQsrHMpQKeCRPcjKnwNy
|
15
tsc1877/task1/project/admin/.editorconfig
Normal file
15
tsc1877/task1/project/admin/.editorconfig
Normal file
@@ -0,0 +1,15 @@
|
||||
# Editor configuration, see http://editorconfig.org
|
||||
root = true
|
||||
[*]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
[*.md]
|
||||
max_line_length = off
|
||||
trim_trailing_whitespace = false
|
||||
[*.yml]
|
||||
[*.{yml,yaml}]
|
||||
indent_size = 2
|
5
tsc1877/task1/project/admin/.env.example
Normal file
5
tsc1877/task1/project/admin/.env.example
Normal file
@@ -0,0 +1,5 @@
|
||||
DB_HOST=localhost
|
||||
DB_PORT=6033
|
||||
DB_NAME=app_db
|
||||
DB_USER=db_user
|
||||
DB_PASSWORD=db_user_pass
|
31
tsc1877/task1/project/admin/.eslintrc.js
Normal file
31
tsc1877/task1/project/admin/.eslintrc.js
Normal file
@@ -0,0 +1,31 @@
|
||||
module.exports = {
|
||||
env: {
|
||||
node: true,
|
||||
es6: true,
|
||||
browser: true,
|
||||
},
|
||||
parser: 'babel-eslint',
|
||||
extends: ['next/core-web-vitals', 'prettier'],
|
||||
parserOptions: {
|
||||
ecmaVersion: 11,
|
||||
sourceType: 'module',
|
||||
project: './jsconfig.json',
|
||||
ecmaFeatures: {
|
||||
jsx: true,
|
||||
modules: true,
|
||||
experimentalObjectRestSpread: true,
|
||||
},
|
||||
},
|
||||
rules: {
|
||||
'padding-line-between-statements': 'off',
|
||||
'lines-around-comment': 'off',
|
||||
'import/newline-after-import': 'off',
|
||||
'react-hooks/rules-of-hooks': 'off',
|
||||
'react/react-in-jsx-scope': 'off',
|
||||
'react/jsx-filename-extension': [1, { extensions: ['.js', '.jsx'] }],
|
||||
'react/display-name': 'off',
|
||||
'@next/next/no-img-element': 'off',
|
||||
'react/no-unescaped-entities': 'off',
|
||||
'import/no-anonymous-default-export': 'off',
|
||||
},
|
||||
};
|
30
tsc1877/task1/project/admin/.eslintrc.js.bak
Normal file
30
tsc1877/task1/project/admin/.eslintrc.js.bak
Normal file
@@ -0,0 +1,30 @@
|
||||
module.exports = {
|
||||
env: {
|
||||
node: true,
|
||||
es6: true,
|
||||
browser: true
|
||||
},
|
||||
parser: 'babel-eslint',
|
||||
extends: ['next/core-web-vitals', 'prettier'],
|
||||
parserOptions: {
|
||||
ecmaVersion: 11,
|
||||
sourceType: 'module',
|
||||
project: './jsconfig.json',
|
||||
ecmaFeatures: {
|
||||
jsx: true,
|
||||
modules: true,
|
||||
experimentalObjectRestSpread: true
|
||||
}
|
||||
},
|
||||
rules: {
|
||||
'react/react-in-jsx-scope': 'off',
|
||||
'react/jsx-filename-extension': [1, { extensions: ['.js', '.jsx'] }],
|
||||
'react/display-name': 'off',
|
||||
'@next/next/no-img-element': 'off',
|
||||
'react/no-unescaped-entities': 'off',
|
||||
'import/no-anonymous-default-export': 'off',
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
39
tsc1877/task1/project/admin/.gitignore
vendored
Normal file
39
tsc1877/task1/project/admin/.gitignore
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
.env
|
||||
.env.local
|
||||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
||||
|
||||
# dependencies
|
||||
/node_modules
|
||||
/.pnp
|
||||
.pnp.js
|
||||
|
||||
# testing
|
||||
/coverage
|
||||
|
||||
# next.js
|
||||
/.next/
|
||||
/out/
|
||||
|
||||
# production
|
||||
/build
|
||||
|
||||
# misc
|
||||
.DS_Store
|
||||
*.pem
|
||||
|
||||
# debug
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
|
||||
# local env files
|
||||
.env.local
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
|
||||
# vercel
|
||||
.vercel
|
||||
|
||||
# typescript
|
||||
*.tsbuildinfo
|
18
tsc1877/task1/project/admin/.prettierrc
Normal file
18
tsc1877/task1/project/admin/.prettierrc
Normal file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"arrowParens": "avoid",
|
||||
"bracketSpacing": true,
|
||||
"htmlWhitespaceSensitivity": "strict",
|
||||
"insertPragma": false,
|
||||
"jsxBracketSameLine": false,
|
||||
"jsxSingleQuote": false,
|
||||
"printWidth": 120,
|
||||
"proseWrap": "preserve",
|
||||
"quoteProps": "as-needed",
|
||||
"requirePragma": false,
|
||||
"semi": true,
|
||||
"singleQuote": true,
|
||||
"tabWidth": 2,
|
||||
"trailingComma": "all",
|
||||
"useTabs": false,
|
||||
"overrides": []
|
||||
}
|
8
tsc1877/task1/project/admin/build.bat
Normal file
8
tsc1877/task1/project/admin/build.bat
Normal file
@@ -0,0 +1,8 @@
|
||||
rmdir /s /q .next
|
||||
|
||||
call yarn
|
||||
call yarn build
|
||||
|
||||
call node ./db_seed/seed_all.js
|
||||
|
||||
yarn start
|
13
tsc1877/task1/project/admin/build.sh
Executable file
13
tsc1877/task1/project/admin/build.sh
Executable file
@@ -0,0 +1,13 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -x
|
||||
|
||||
rm -rf /s /q .next
|
||||
rm -rf /s /q node_modules/*
|
||||
|
||||
yarn
|
||||
yarn build
|
||||
|
||||
node ./db_seed/seed_all.js
|
||||
|
||||
yarn start
|
2
tsc1877/task1/project/admin/clear.bat
Normal file
2
tsc1877/task1/project/admin/clear.bat
Normal file
@@ -0,0 +1,2 @@
|
||||
call rmdir /s /q node_modules
|
||||
call rmdir /s /q .next
|
53
tsc1877/task1/project/admin/db_seed/auth.js
Normal file
53
tsc1877/task1/project/admin/db_seed/auth.js
Normal file
@@ -0,0 +1,53 @@
|
||||
const { Sequelize, DataTypes } = require('sequelize');
|
||||
const bcrypt = require('bcrypt');
|
||||
const { sequelize } = require('./model');
|
||||
|
||||
function delay(time_ms) {
|
||||
return new Promise((res, rej) => {
|
||||
setTimeout(() => {
|
||||
res();
|
||||
}, time_ms);
|
||||
});
|
||||
}
|
||||
|
||||
const Auth = sequelize.define(
|
||||
'Auths',
|
||||
{
|
||||
uid: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true, unique: true },
|
||||
username: { type: DataTypes.STRING, allowNull: false },
|
||||
password: { type: DataTypes.STRING, allowNull: false },
|
||||
session: { type: DataTypes.STRING, allowNull: false, defaultValue: '' },
|
||||
role: { type: DataTypes.STRING, allowNull: false, defaultValue: 'customer' },
|
||||
},
|
||||
{ timestamps: false },
|
||||
);
|
||||
|
||||
async function hashPassword(plainTextPassword) {
|
||||
const saltRounds = 10;
|
||||
return await bcrypt.hash(plainTextPassword, saltRounds);
|
||||
}
|
||||
|
||||
(async () => {
|
||||
try {
|
||||
await sequelize.authenticate();
|
||||
console.log('Connection has been established successfully.');
|
||||
|
||||
// create table
|
||||
await Auth.drop();
|
||||
await sequelize.sync();
|
||||
|
||||
let user_row, password;
|
||||
user_row = await Auth.create({
|
||||
username: 'admin@vtkhmall.com',
|
||||
password: await hashPassword('nimda'),
|
||||
role: 'admin',
|
||||
});
|
||||
user_row = await Auth.create({ username: 'cust1@vtkhmall.com', password: await hashPassword('1tsuc') });
|
||||
user_row = await Auth.create({ username: 'cust2@vtkhmall.com', password: await hashPassword('2tsuc') });
|
||||
user_row = await Auth.create({ username: 'cust3@vtkhmall.com', password: await hashPassword('3tsuc') });
|
||||
|
||||
// await sequelize.close();
|
||||
} catch (error) {
|
||||
console.error('Unable to connect to the database:', error);
|
||||
}
|
||||
})();
|
54
tsc1877/task1/project/admin/db_seed/categories.js
Normal file
54
tsc1877/task1/project/admin/db_seed/categories.js
Normal file
@@ -0,0 +1,54 @@
|
||||
const { Sequelize, DataTypes } = require('sequelize');
|
||||
const { sequelize } = require('./model');
|
||||
|
||||
// const sequelize = new Sequelize('app_db', 'db_user', 'db_user_pass', {
|
||||
// host: 'mysql',
|
||||
// port: 3306,
|
||||
// dialect: 'mysql',
|
||||
// });
|
||||
|
||||
const Category = sequelize.define(
|
||||
'Categories',
|
||||
{
|
||||
cid: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true, unique: true },
|
||||
name: { type: DataTypes.STRING, allowNull: false },
|
||||
description: { type: DataTypes.STRING, allowNull: false },
|
||||
},
|
||||
{ timestamps: false },
|
||||
);
|
||||
|
||||
(async () => {
|
||||
try {
|
||||
await sequelize.authenticate();
|
||||
console.log('Connection has been established successfully.');
|
||||
|
||||
// create table
|
||||
await Category.drop();
|
||||
await sequelize.sync();
|
||||
|
||||
let category;
|
||||
|
||||
category = await Category.create({ name: 'Bakery', description: 'Bread, pastries, cakes, cookies' });
|
||||
category = await Category.create({ name: 'Dairy', description: 'Milk, cheese, eggs, yogurt, butter' });
|
||||
category = await Category.create({
|
||||
name: 'Meat & Seafood',
|
||||
description: 'Raw meat products, poultry, fish, shellfish',
|
||||
});
|
||||
category = await Category.create({
|
||||
name: 'Deli Counter',
|
||||
description: 'Prepared foods such as sandwiches, salads, and cold cuts',
|
||||
});
|
||||
category = await Category.create({
|
||||
name: 'Frozen Foods',
|
||||
description: 'Ice cream, frozen meals, pizza, vegetables, berries',
|
||||
});
|
||||
category = await Category.create({
|
||||
name: 'Pantry Staples',
|
||||
description: 'Pasta, rice, sauces, oils, vinegar, spices, canned goods',
|
||||
});
|
||||
|
||||
const categories = await Category.findAll();
|
||||
} catch (error) {
|
||||
console.error('Unable to connect to the database:', error);
|
||||
}
|
||||
})();
|
32
tsc1877/task1/project/admin/db_seed/helloworld.js
Normal file
32
tsc1877/task1/project/admin/db_seed/helloworld.js
Normal file
@@ -0,0 +1,32 @@
|
||||
const { Sequelize, DataTypes } = require('sequelize');
|
||||
const { sequelize } = require('./model');
|
||||
|
||||
const User = sequelize.define(
|
||||
'User',
|
||||
{
|
||||
id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true, unique: true },
|
||||
firstName: { type: DataTypes.STRING, allowNull: false },
|
||||
lastName: { type: DataTypes.STRING, allowNull: false },
|
||||
},
|
||||
{ timestamps: false },
|
||||
);
|
||||
|
||||
(async () => {
|
||||
try {
|
||||
await sequelize.authenticate();
|
||||
console.log('Connection has been established successfully.');
|
||||
|
||||
// create table
|
||||
await sequelize.sync();
|
||||
|
||||
let users = await User.findAll({ attributes: ['firstName'] });
|
||||
User.destroy({ truncate: true, cascade: true, force: true });
|
||||
|
||||
const user = await User.create({ firstName: 'John', lastName: 'Doe' });
|
||||
users = await User.findAll();
|
||||
|
||||
// await sequelize.close();
|
||||
} catch (error) {
|
||||
console.error('Unable to connect to the database:', error);
|
||||
}
|
||||
})();
|
38
tsc1877/task1/project/admin/db_seed/item.js
Normal file
38
tsc1877/task1/project/admin/db_seed/item.js
Normal file
@@ -0,0 +1,38 @@
|
||||
const { Sequelize, DataTypes } = require('sequelize');
|
||||
const { sequelize } = require('./model');
|
||||
|
||||
const Item = sequelize.define(
|
||||
'Items',
|
||||
{
|
||||
item_id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true, unique: true },
|
||||
pid: { type: DataTypes.INTEGER },
|
||||
description: { type: DataTypes.STRING, allowNull: false },
|
||||
sold: { type: DataTypes.BOOLEAN, allowNull: false, defaultValue: false },
|
||||
},
|
||||
{ timestamps: false },
|
||||
);
|
||||
|
||||
(async () => {
|
||||
try {
|
||||
await sequelize.authenticate();
|
||||
console.log('Connection has been established successfully.');
|
||||
|
||||
await Item.drop();
|
||||
|
||||
await sequelize.sync();
|
||||
for (var j = 1; j <= 25; j++) {
|
||||
for (var i = 0; i < 10; i++) {
|
||||
await Item.create({
|
||||
// get remainder of i divided by 3
|
||||
// pid: (i % 25) + 1,
|
||||
pid: j,
|
||||
description: `test item ${i}`,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// await sequelize.close();
|
||||
} catch (error) {
|
||||
console.error('Unable to connect to the database:', error);
|
||||
}
|
||||
})();
|
14
tsc1877/task1/project/admin/db_seed/model.js
Normal file
14
tsc1877/task1/project/admin/db_seed/model.js
Normal file
@@ -0,0 +1,14 @@
|
||||
// dotenv to read .env file
|
||||
require('dotenv').config();
|
||||
|
||||
const { Sequelize, DataTypes } = require('sequelize');
|
||||
|
||||
const { DB_HOST, DB_PORT, DB_NAME, DB_USER, DB_PASSWORD } = process.env;
|
||||
|
||||
const sequelize = new Sequelize(DB_NAME, DB_USER, DB_PASSWORD, {
|
||||
host: DB_HOST,
|
||||
port: DB_PORT,
|
||||
dialect: 'mysql',
|
||||
});
|
||||
|
||||
module.exports = { sequelize };
|
86
tsc1877/task1/project/admin/db_seed/order.js
Normal file
86
tsc1877/task1/project/admin/db_seed/order.js
Normal file
@@ -0,0 +1,86 @@
|
||||
const { Sequelize, DataTypes } = require('sequelize');
|
||||
const { sequelize } = require('./model');
|
||||
const crypto = require('crypto');
|
||||
|
||||
const Order = sequelize.define(
|
||||
'Orders',
|
||||
{
|
||||
order_id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true, unique: true },
|
||||
invoice_id: { type: DataTypes.STRING, allowNull: false },
|
||||
username: { type: DataTypes.STRING, allowNull: false },
|
||||
custom_id: { type: DataTypes.STRING, allowNull: false },
|
||||
amount: { type: DataTypes.STRING, allowNull: false },
|
||||
total_price: { type: DataTypes.DECIMAL, allowNull: false },
|
||||
currency_code: { type: DataTypes.STRING, allowNull: false },
|
||||
items: { type: DataTypes.STRING, allowNull: false },
|
||||
order_status: { type: DataTypes.STRING, allowNull: false, defaultValue: 'NOT_PAID' },
|
||||
salt: { type: DataTypes.STRING, allowNull: false },
|
||||
},
|
||||
{ timestamps: true },
|
||||
);
|
||||
|
||||
function genSalt() {
|
||||
return crypto.randomBytes(16).toString('hex');
|
||||
}
|
||||
|
||||
function createMD5HashWithSalt(inputString, salt) {
|
||||
// Prepend the salt to the inputString
|
||||
const saltedInput = salt + inputString;
|
||||
|
||||
// Proceed with the MD5 hash
|
||||
const hash = crypto.createHash('md5').update(saltedInput).digest('hex');
|
||||
|
||||
// Optionally, you might want to return both the hash and the salt
|
||||
// for storage, so you can verify the input against the hash later.
|
||||
return { salt, hash };
|
||||
}
|
||||
|
||||
(async () => {
|
||||
try {
|
||||
await sequelize.authenticate();
|
||||
console.log('Connection has been established successfully.');
|
||||
const item_name = 'item_name';
|
||||
const quantity = parseInt('10');
|
||||
const unit_price = parseInt('1');
|
||||
const currency_code = 'HKD';
|
||||
const amount = parseInt(20);
|
||||
const total_price = parseInt(20);
|
||||
const email_name = 'cust1@vtkhmall.com';
|
||||
|
||||
// create table
|
||||
await Order.drop();
|
||||
|
||||
await sequelize.sync();
|
||||
|
||||
const order = await Order.create({
|
||||
invoice_id: crypto.randomUUID(),
|
||||
username: email_name,
|
||||
custom_id: createMD5HashWithSalt(
|
||||
JSON.stringify(
|
||||
[
|
||||
{ item_name, quantity, unit_price },
|
||||
{ item_name, quantity, unit_price },
|
||||
],
|
||||
total_price,
|
||||
currency_code,
|
||||
email_name,
|
||||
),
|
||||
genSalt(),
|
||||
)['hash'],
|
||||
amount,
|
||||
total_price,
|
||||
currency_code,
|
||||
items: JSON.stringify([
|
||||
{ item_name, quantity, unit_price },
|
||||
{ item_name, quantity, unit_price },
|
||||
]),
|
||||
order_status: 'NOT_PAID',
|
||||
salt: '12321',
|
||||
});
|
||||
orders = await Order.findAll();
|
||||
|
||||
// await sequelize.close();
|
||||
} catch (error) {
|
||||
console.error('Unable to connect to the database:', error);
|
||||
}
|
||||
})();
|
36
tsc1877/task1/project/admin/db_seed/products.js
Normal file
36
tsc1877/task1/project/admin/db_seed/products.js
Normal file
@@ -0,0 +1,36 @@
|
||||
const { Sequelize, DataTypes } = require('sequelize');
|
||||
const { sequelize } = require('./model');
|
||||
|
||||
// const sequelize = new Sequelize('app_db', 'db_user', 'db_user_pass', {
|
||||
// host: 'mysql',
|
||||
// port: 3306,
|
||||
// dialect: 'mysql',
|
||||
// });
|
||||
|
||||
const Product = sequelize.define(
|
||||
'Products',
|
||||
{
|
||||
pid: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true, unique: true },
|
||||
cid: { type: DataTypes.INTEGER, allowNull: false },
|
||||
name: { type: DataTypes.STRING, allowNull: false },
|
||||
description: { type: DataTypes.STRING, allowNull: false },
|
||||
price: { type: DataTypes.DECIMAL, allowNull: false },
|
||||
product_image: { type: DataTypes.STRING, allowNull: true, defaultValue: '' },
|
||||
},
|
||||
{ timestamps: false },
|
||||
);
|
||||
|
||||
(async () => {
|
||||
try {
|
||||
await sequelize.authenticate();
|
||||
console.log('Connection has been established successfully.');
|
||||
|
||||
await Product.drop();
|
||||
|
||||
await sequelize.sync();
|
||||
|
||||
// await sequelize.close();
|
||||
} catch (error) {
|
||||
console.error('Unable to connect to the database:', error);
|
||||
}
|
||||
})();
|
86
tsc1877/task1/project/admin/db_seed/products_cid_1.js
Normal file
86
tsc1877/task1/project/admin/db_seed/products_cid_1.js
Normal file
@@ -0,0 +1,86 @@
|
||||
const { Sequelize, DataTypes } = require('sequelize');
|
||||
const { sequelize } = require('./model');
|
||||
|
||||
// const sequelize = new Sequelize('app_db', 'db_user', 'db_user_pass', {
|
||||
// host: 'mysql',
|
||||
// port: 3306,
|
||||
// dialect: 'mysql',
|
||||
// });
|
||||
|
||||
const Product = sequelize.define(
|
||||
'Products',
|
||||
{
|
||||
pid: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true, unique: true },
|
||||
cid: { type: DataTypes.INTEGER, allowNull: false },
|
||||
name: { type: DataTypes.STRING, allowNull: false },
|
||||
product_image: { type: DataTypes.STRING, allowNull: false },
|
||||
description: { type: DataTypes.STRING, allowNull: false },
|
||||
price: { type: DataTypes.FLOAT, allowNull: false },
|
||||
},
|
||||
{ timestamps: false },
|
||||
);
|
||||
|
||||
(async () => {
|
||||
try {
|
||||
await sequelize.authenticate();
|
||||
console.log('Connection has been established successfully.');
|
||||
|
||||
// create table
|
||||
await sequelize.sync();
|
||||
|
||||
let products = [
|
||||
{
|
||||
cid: 1,
|
||||
name: 'French Baguette',
|
||||
description: 'A long, crusty loaf of French bread with a soft interior.',
|
||||
price: 5.5,
|
||||
product_image: 'BREAD1',
|
||||
},
|
||||
{
|
||||
cid: 1,
|
||||
name: 'Whole Wheat Bread',
|
||||
description: 'A nutritious bread made with whole wheat flour and grains.',
|
||||
price: 6.5,
|
||||
product_image: 'BREAD2',
|
||||
},
|
||||
{
|
||||
cid: 1,
|
||||
name: 'Croissants',
|
||||
description: 'Buttery, flaky pastries often enjoyed with coffee or tea.',
|
||||
price: 8.5,
|
||||
product_image: 'BREAD3',
|
||||
},
|
||||
{
|
||||
cid: 1,
|
||||
name: 'Donuts',
|
||||
description: 'Sweet, fried pastries with a variety of toppings and fillings.',
|
||||
price: 4.95,
|
||||
product_image: 'BREAD4',
|
||||
},
|
||||
{
|
||||
cid: 1,
|
||||
name: 'Whole Wheat Bread',
|
||||
description: 'A nutritious bread made with whole wheat flour and grains.',
|
||||
price: 6.5,
|
||||
product_image: 'BREAD2',
|
||||
},
|
||||
{
|
||||
cid: 1,
|
||||
name: 'Croissants',
|
||||
description: 'Buttery, flaky pastries often enjoyed with coffee or tea.',
|
||||
price: 8.5,
|
||||
product_image: 'BREAD3',
|
||||
},
|
||||
];
|
||||
|
||||
for (var i = 0; i < products.length; i++) {
|
||||
await Product.create(products[i]);
|
||||
}
|
||||
|
||||
const categories = await Product.findAll();
|
||||
|
||||
// await sequelize.close();
|
||||
} catch (error) {
|
||||
console.error('Unable to connect to the database:', error);
|
||||
}
|
||||
})();
|
72
tsc1877/task1/project/admin/db_seed/products_cid_2.js
Normal file
72
tsc1877/task1/project/admin/db_seed/products_cid_2.js
Normal file
@@ -0,0 +1,72 @@
|
||||
const { Sequelize, DataTypes } = require('sequelize');
|
||||
const { sequelize } = require('./model');
|
||||
|
||||
// const sequelize = new Sequelize('app_db', 'db_user', 'db_user_pass', {
|
||||
// host: 'mysql',
|
||||
// port: 3306,
|
||||
// dialect: 'mysql',
|
||||
// });
|
||||
|
||||
const Product = sequelize.define(
|
||||
'Products',
|
||||
{
|
||||
pid: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true, unique: true },
|
||||
cid: { type: DataTypes.INTEGER, allowNull: false },
|
||||
name: { type: DataTypes.STRING, allowNull: false },
|
||||
description: { type: DataTypes.STRING, allowNull: false },
|
||||
price: { type: DataTypes.DECIMAL, allowNull: false },
|
||||
product_image: { type: DataTypes.STRING, allowNull: false },
|
||||
},
|
||||
{ timestamps: false },
|
||||
);
|
||||
|
||||
(async () => {
|
||||
try {
|
||||
await sequelize.authenticate();
|
||||
console.log('Connection has been established successfully.');
|
||||
|
||||
// create table
|
||||
await sequelize.sync();
|
||||
|
||||
let products = [
|
||||
{
|
||||
cid: 2,
|
||||
name: 'Milk',
|
||||
description: 'A nutritious beverage made from the milk of cows, goats, or other mammals.',
|
||||
price: 5.5,
|
||||
product_image: 'DAIRY_1',
|
||||
},
|
||||
{
|
||||
cid: 2,
|
||||
name: 'Cheese',
|
||||
description: 'A versatile dairy product made from milk, available in a variety of flavors and textures.',
|
||||
price: 6.5,
|
||||
product_image: 'DAIRY_2',
|
||||
},
|
||||
{
|
||||
cid: 2,
|
||||
name: 'Yogurt',
|
||||
description: 'A creamy, fermented dairy product that comes in many flavors and styles.',
|
||||
price: 8.5,
|
||||
product_image: 'DAIRY_3',
|
||||
},
|
||||
{
|
||||
cid: 2,
|
||||
name: 'Butter',
|
||||
description: 'A dairy product made by churning cream, used for cooking and baking.',
|
||||
price: 4.95,
|
||||
product_image: 'DAIRY_4',
|
||||
},
|
||||
];
|
||||
|
||||
for (var i = 0; i < products.length; i++) {
|
||||
await Product.create(products[i]);
|
||||
}
|
||||
|
||||
const categories = await Product.findAll();
|
||||
|
||||
// await sequelize.close();
|
||||
} catch (error) {
|
||||
console.error('Unable to connect to the database:', error);
|
||||
}
|
||||
})();
|
72
tsc1877/task1/project/admin/db_seed/products_cid_3.js
Normal file
72
tsc1877/task1/project/admin/db_seed/products_cid_3.js
Normal file
@@ -0,0 +1,72 @@
|
||||
const { Sequelize, DataTypes } = require('sequelize');
|
||||
const { sequelize } = require('./model');
|
||||
|
||||
// const sequelize = new Sequelize('app_db', 'db_user', 'db_user_pass', {
|
||||
// host: 'mysql',
|
||||
// port: 3306,
|
||||
// dialect: 'mysql',
|
||||
// });
|
||||
|
||||
const Product = sequelize.define(
|
||||
'Products',
|
||||
{
|
||||
pid: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true, unique: true },
|
||||
cid: { type: DataTypes.INTEGER, allowNull: false },
|
||||
name: { type: DataTypes.STRING, allowNull: false },
|
||||
description: { type: DataTypes.STRING, allowNull: false },
|
||||
price: { type: DataTypes.DECIMAL, allowNull: false },
|
||||
product_image: { type: DataTypes.STRING, allowNull: true, defaultValue: '' },
|
||||
},
|
||||
{ timestamps: false },
|
||||
);
|
||||
|
||||
(async () => {
|
||||
try {
|
||||
await sequelize.authenticate();
|
||||
console.log('Connection has been established successfully.');
|
||||
|
||||
// create table
|
||||
await sequelize.sync();
|
||||
|
||||
let products = [
|
||||
{
|
||||
cid: 3,
|
||||
name: 'Chicken',
|
||||
description: 'A versatile and popular type of poultry, available in many cuts and preparations.',
|
||||
price: 9.95,
|
||||
product_image: 'MEAT1',
|
||||
},
|
||||
{
|
||||
cid: 3,
|
||||
name: 'Beef',
|
||||
description: 'A type of red meat that comes from cows, available in a variety of cuts and grades.',
|
||||
price: 13.5,
|
||||
product_image: 'MEAT2',
|
||||
},
|
||||
{
|
||||
cid: 3,
|
||||
name: 'Pork',
|
||||
description: 'A type of meat that comes from pigs, available in many cuts and preparations.',
|
||||
price: 27.8,
|
||||
product_image: 'MEAT3',
|
||||
},
|
||||
{
|
||||
cid: 3,
|
||||
name: 'Lamb',
|
||||
description: 'A type of red meat that comes from sheep, available in many cuts and preparations.',
|
||||
price: 25.95,
|
||||
product_image: 'MEAT4',
|
||||
},
|
||||
];
|
||||
|
||||
for (var i = 0; i < products.length; i++) {
|
||||
await Product.create(products[i]);
|
||||
}
|
||||
|
||||
const categories = await Product.findAll();
|
||||
|
||||
// await sequelize.close();
|
||||
} catch (error) {
|
||||
console.error('Unable to connect to the database:', error);
|
||||
}
|
||||
})();
|
72
tsc1877/task1/project/admin/db_seed/products_cid_4.js
Normal file
72
tsc1877/task1/project/admin/db_seed/products_cid_4.js
Normal file
@@ -0,0 +1,72 @@
|
||||
const { Sequelize, DataTypes } = require('sequelize');
|
||||
const { sequelize } = require('./model');
|
||||
|
||||
// const sequelize = new Sequelize('app_db', 'db_user', 'db_user_pass', {
|
||||
// host: 'mysql',
|
||||
// port: 3306,
|
||||
// dialect: 'mysql',
|
||||
// });
|
||||
|
||||
const Product = sequelize.define(
|
||||
'Products',
|
||||
{
|
||||
pid: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true, unique: true },
|
||||
cid: { type: DataTypes.INTEGER, allowNull: false },
|
||||
name: { type: DataTypes.STRING, allowNull: false },
|
||||
description: { type: DataTypes.STRING, allowNull: false },
|
||||
price: { type: DataTypes.DECIMAL, allowNull: false },
|
||||
product_image: { type: DataTypes.STRING, allowNull: false },
|
||||
},
|
||||
{ timestamps: false },
|
||||
);
|
||||
|
||||
(async () => {
|
||||
try {
|
||||
await sequelize.authenticate();
|
||||
console.log('Connection has been established successfully.');
|
||||
|
||||
// create table
|
||||
await sequelize.sync();
|
||||
|
||||
let products = [
|
||||
{
|
||||
cid: 4,
|
||||
name: 'Sliced Meats',
|
||||
description: 'Deli meats such as ham, turkey, salami, and roast beef, sliced to order.',
|
||||
price: 6.95,
|
||||
product_image: 'DELI_1',
|
||||
},
|
||||
{
|
||||
cid: 4,
|
||||
name: 'Cheese',
|
||||
description: 'A variety of cheeses, such as cheddar, Swiss, and mozzarella, sliced to order.',
|
||||
price: 7.5,
|
||||
product_image: 'DELI_2',
|
||||
},
|
||||
{
|
||||
cid: 4,
|
||||
name: 'Prepared Salads',
|
||||
description: 'Salads such as pasta salad, potato salad, and coleslaw, made fresh in-store.',
|
||||
price: 8.5,
|
||||
product_image: 'DELI_3',
|
||||
},
|
||||
{
|
||||
cid: 4,
|
||||
name: 'Rotisserie Chicken',
|
||||
description: 'Whole chickens that have been seasoned and roasted in-store, ready to take home and serve.',
|
||||
price: 7.5,
|
||||
product_image: 'DELI_4',
|
||||
},
|
||||
];
|
||||
|
||||
for (var i = 0; i < products.length; i++) {
|
||||
await Product.create(products[i]);
|
||||
}
|
||||
|
||||
const categories = await Product.findAll();
|
||||
|
||||
// await sequelize.close();
|
||||
} catch (error) {
|
||||
console.error('Unable to connect to the database:', error);
|
||||
}
|
||||
})();
|
75
tsc1877/task1/project/admin/db_seed/products_cid_5.js
Normal file
75
tsc1877/task1/project/admin/db_seed/products_cid_5.js
Normal file
@@ -0,0 +1,75 @@
|
||||
const { Sequelize, DataTypes } = require('sequelize');
|
||||
const { sequelize } = require('./model');
|
||||
|
||||
// const sequelize = new Sequelize('app_db', 'db_user', 'db_user_pass', {
|
||||
// host: 'mysql',
|
||||
// port: 3306,
|
||||
// dialect: 'mysql',
|
||||
// });
|
||||
|
||||
const Product = sequelize.define(
|
||||
'Products',
|
||||
{
|
||||
pid: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true, unique: true },
|
||||
cid: { type: DataTypes.INTEGER, allowNull: false },
|
||||
name: { type: DataTypes.STRING, allowNull: false },
|
||||
product_image: { type: DataTypes.STRING, allowNull: false },
|
||||
description: { type: DataTypes.STRING, allowNull: false },
|
||||
price: { type: DataTypes.DECIMAL, allowNull: false },
|
||||
},
|
||||
{ timestamps: false },
|
||||
);
|
||||
|
||||
(async () => {
|
||||
try {
|
||||
await sequelize.authenticate();
|
||||
console.log('Connection has been established successfully.');
|
||||
|
||||
// create table
|
||||
await sequelize.sync();
|
||||
|
||||
let products = [
|
||||
{
|
||||
cid: 5,
|
||||
name: 'Frozen Vegetables',
|
||||
description: 'A variety of vegetables, such as peas, corn, and broccoli, frozen at peak freshness.',
|
||||
price: 5.5,
|
||||
product_image: 'FROZEN_1',
|
||||
},
|
||||
{
|
||||
cid: 5,
|
||||
name: 'Frozen Seafood',
|
||||
description: 'A variety of seafood, such as shrimp, fish, and scallops, frozen for freshness and convenience.',
|
||||
|
||||
price: 6.5,
|
||||
product_image: 'FROZEN_2',
|
||||
},
|
||||
{
|
||||
cid: 5,
|
||||
name: 'Frozen Meals',
|
||||
description: 'Pre-made meals such as pizza, lasagna, and stir-fry, available for quick and easy dinners.',
|
||||
|
||||
price: 8.5,
|
||||
product_image: 'FROZEN_3',
|
||||
},
|
||||
{
|
||||
cid: 5,
|
||||
name: 'Frozen Fruits',
|
||||
description: 'A variety of fruits, such as berries, mango, and pineapple, frozen at peak freshness.',
|
||||
|
||||
price: 4.95,
|
||||
product_image: 'FROZEN_4',
|
||||
},
|
||||
];
|
||||
|
||||
for (var i = 0; i < products.length; i++) {
|
||||
await Product.create(products[i]);
|
||||
}
|
||||
|
||||
const categories = await Product.findAll();
|
||||
|
||||
// await sequelize.close();
|
||||
} catch (error) {
|
||||
console.error('Unable to connect to the database:', error);
|
||||
}
|
||||
})();
|
86
tsc1877/task1/project/admin/db_seed/products_cid_6.js
Normal file
86
tsc1877/task1/project/admin/db_seed/products_cid_6.js
Normal file
@@ -0,0 +1,86 @@
|
||||
const { Sequelize, DataTypes } = require('sequelize');
|
||||
const { sequelize } = require('./model');
|
||||
|
||||
// const sequelize = new Sequelize('app_db', 'db_user', 'db_user_pass', {
|
||||
// host: 'mysql',
|
||||
// port: 3306,
|
||||
// dialect: 'mysql',
|
||||
// });
|
||||
|
||||
const Product = sequelize.define(
|
||||
'Products',
|
||||
{
|
||||
pid: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true, unique: true },
|
||||
cid: { type: DataTypes.INTEGER, allowNull: false },
|
||||
name: { type: DataTypes.STRING, allowNull: false },
|
||||
product_image: { type: DataTypes.STRING, allowNull: false },
|
||||
description: { type: DataTypes.STRING, allowNull: false },
|
||||
price: { type: DataTypes.DECIMAL, allowNull: false },
|
||||
},
|
||||
{ timestamps: false },
|
||||
);
|
||||
|
||||
(async () => {
|
||||
try {
|
||||
await sequelize.authenticate();
|
||||
console.log('Connection has been established successfully.');
|
||||
|
||||
// create table
|
||||
await sequelize.sync();
|
||||
|
||||
let products = [
|
||||
{
|
||||
cid: 6,
|
||||
name: 'Pasta',
|
||||
description: 'A variety of pasta shapes and types, such as spaghetti, macaroni, and lasagna noodles.',
|
||||
price: 5.5,
|
||||
product_image: 'PANTRY_1',
|
||||
},
|
||||
{
|
||||
cid: 6,
|
||||
name: 'Rice',
|
||||
description: 'A variety of rice types, such as white rice, brown rice, and jasmine rice.',
|
||||
price: 6.5,
|
||||
product_image: 'PANTRY_2',
|
||||
},
|
||||
{
|
||||
cid: 6,
|
||||
name: 'Canned Beans',
|
||||
description: 'A variety of beans, such as black beans, kidney beans, and chickpeas, canned for convenience.',
|
||||
price: 8.5,
|
||||
product_image: 'PANTRY_3',
|
||||
},
|
||||
{
|
||||
cid: 6,
|
||||
name: 'Canned Tomatoes',
|
||||
description: 'A variety of canned tomatoes, such as diced tomatoes, crushed tomatoes, and tomato sauce.',
|
||||
price: 4.95,
|
||||
product_image: 'PANTRY_4',
|
||||
},
|
||||
{
|
||||
cid: 6,
|
||||
name: 'Canned Beans',
|
||||
description: 'A variety of beans, such as black beans, kidney beans, and chickpeas, canned for convenience.',
|
||||
price: 8.5,
|
||||
product_image: 'PANTRY_3',
|
||||
},
|
||||
{
|
||||
cid: 6,
|
||||
name: 'Canned Tomatoes',
|
||||
description: 'A variety of canned tomatoes, such as diced tomatoes, crushed tomatoes, and tomato sauce.',
|
||||
price: 4.95,
|
||||
product_image: 'PANTRY_4',
|
||||
},
|
||||
];
|
||||
|
||||
for (var i = 0; i < products.length; i++) {
|
||||
await Product.create(products[i]);
|
||||
}
|
||||
|
||||
const categories = await Product.findAll();
|
||||
|
||||
// await sequelize.close();
|
||||
} catch (error) {
|
||||
console.error('Unable to connect to the database:', error);
|
||||
}
|
||||
})();
|
32
tsc1877/task1/project/admin/db_seed/seed_all.js
Normal file
32
tsc1877/task1/project/admin/db_seed/seed_all.js
Normal file
@@ -0,0 +1,32 @@
|
||||
function delay(time_ms) {
|
||||
return new Promise((res, rej) => {
|
||||
setTimeout(() => {
|
||||
res();
|
||||
}, time_ms);
|
||||
});
|
||||
}
|
||||
|
||||
(async () => {
|
||||
await require('./helloworld');
|
||||
await delay(100);
|
||||
|
||||
await require('./categories');
|
||||
await delay(100);
|
||||
|
||||
await require('./products');
|
||||
await delay(100);
|
||||
|
||||
await require('./products_cid_1');
|
||||
await require('./products_cid_2');
|
||||
await require('./products_cid_3');
|
||||
await require('./products_cid_4');
|
||||
await require('./products_cid_5');
|
||||
await require('./products_cid_6');
|
||||
|
||||
await require('./auth');
|
||||
|
||||
await require('./item');
|
||||
await require('./order');
|
||||
|
||||
console.log('done');
|
||||
})();
|
45
tsc1877/task1/project/admin/db_seed_local/auth.js
Normal file
45
tsc1877/task1/project/admin/db_seed_local/auth.js
Normal file
@@ -0,0 +1,45 @@
|
||||
const { Sequelize, DataTypes } = require('sequelize');
|
||||
const bcrypt = require('bcrypt');
|
||||
|
||||
const sequelize = new Sequelize('app_db', 'db_user', 'db_user_pass', {
|
||||
host: 'mysql',
|
||||
port: 3306,
|
||||
dialect: 'mysql',
|
||||
});
|
||||
|
||||
const Auth = sequelize.define(
|
||||
'Auths',
|
||||
{
|
||||
uid: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true, unique: true },
|
||||
username: { type: DataTypes.STRING, allowNull: false },
|
||||
password: { type: DataTypes.STRING, allowNull: false },
|
||||
},
|
||||
{ timestamps: false },
|
||||
);
|
||||
|
||||
async function hashPassword(plainTextPassword) {
|
||||
const saltRounds = 10;
|
||||
return await bcrypt.hash(plainTextPassword, saltRounds);
|
||||
}
|
||||
|
||||
(async () => {
|
||||
try {
|
||||
await sequelize.authenticate();
|
||||
console.log('Connection has been established successfully.');
|
||||
|
||||
// create table
|
||||
await sequelize.sync();
|
||||
|
||||
await Auth.destroy({ truncate: true, cascade: true, force: true });
|
||||
|
||||
let user_row, password;
|
||||
user_row = await Auth.create({ username: 'admin@vtkhmall.com', password: await hashPassword('nimda') });
|
||||
user_row = await Auth.create({ username: 'cust1@vtkhmall.com', password: await hashPassword('1tsuc') });
|
||||
user_row = await Auth.create({ username: 'cust2@vtkhmall.com', password: await hashPassword('2tsuc') });
|
||||
user_row = await Auth.create({ username: 'cust3@vtkhmall.com', password: await hashPassword('3tsuc') });
|
||||
|
||||
await sequelize.close();
|
||||
} catch (error) {
|
||||
console.error('Unable to connect to the database:', error);
|
||||
}
|
||||
})();
|
56
tsc1877/task1/project/admin/db_seed_local/categories.js
Normal file
56
tsc1877/task1/project/admin/db_seed_local/categories.js
Normal file
@@ -0,0 +1,56 @@
|
||||
const { Sequelize, DataTypes } = require('sequelize');
|
||||
|
||||
const sequelize = new Sequelize('app_db', 'db_user', 'db_user_pass', {
|
||||
host: 'mysql',
|
||||
port: 3306,
|
||||
dialect: 'mysql',
|
||||
});
|
||||
|
||||
const Category = sequelize.define(
|
||||
'Categories',
|
||||
{
|
||||
cid: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true, unique: true },
|
||||
name: { type: DataTypes.STRING, allowNull: false },
|
||||
description: { type: DataTypes.STRING, allowNull: false },
|
||||
},
|
||||
{ timestamps: false },
|
||||
);
|
||||
|
||||
(async () => {
|
||||
try {
|
||||
await sequelize.authenticate();
|
||||
console.log('Connection has been established successfully.');
|
||||
|
||||
// create table
|
||||
await sequelize.sync();
|
||||
|
||||
await Category.destroy({ truncate: true, cascade: true, force: true });
|
||||
|
||||
let category;
|
||||
|
||||
category = await Category.create({ name: 'Bakery', description: 'Bread, pastries, cakes, cookies' });
|
||||
category = await Category.create({ name: 'Dairy', description: 'Milk, cheese, eggs, yogurt, butter' });
|
||||
category = await Category.create({
|
||||
name: 'Meat & Seafood',
|
||||
description: 'Raw meat products, poultry, fish, shellfish',
|
||||
});
|
||||
category = await Category.create({
|
||||
name: 'Deli Counter',
|
||||
description: 'Prepared foods such as sandwiches, salads, and cold cuts',
|
||||
});
|
||||
category = await Category.create({
|
||||
name: 'Frozen Foods',
|
||||
description: 'Ice cream, frozen meals, pizza, vegetables, berries',
|
||||
});
|
||||
category = await Category.create({
|
||||
name: 'Pantry Staples',
|
||||
description: 'Pasta, rice, sauces, oils, vinegar, spices, canned goods',
|
||||
});
|
||||
|
||||
const categories = await Category.findAll();
|
||||
|
||||
await sequelize.close();
|
||||
} catch (error) {
|
||||
console.error('Unable to connect to the database:', error);
|
||||
}
|
||||
})();
|
37
tsc1877/task1/project/admin/db_seed_local/helloworld.js
Normal file
37
tsc1877/task1/project/admin/db_seed_local/helloworld.js
Normal file
@@ -0,0 +1,37 @@
|
||||
const { Sequelize, DataTypes } = require('sequelize');
|
||||
|
||||
const sequelize = new Sequelize('app_db', 'db_user', 'db_user_pass', {
|
||||
host: 'mysql',
|
||||
port: 3306,
|
||||
dialect: 'mysql',
|
||||
});
|
||||
|
||||
const User = sequelize.define(
|
||||
'User',
|
||||
{
|
||||
id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true, unique: true },
|
||||
firstName: { type: DataTypes.STRING, allowNull: false },
|
||||
lastName: { type: DataTypes.STRING, allowNull: false },
|
||||
},
|
||||
{ timestamps: false },
|
||||
);
|
||||
|
||||
(async () => {
|
||||
try {
|
||||
await sequelize.authenticate();
|
||||
console.log('Connection has been established successfully.');
|
||||
|
||||
// create table
|
||||
await sequelize.sync();
|
||||
|
||||
let users = await User.findAll({ attributes: ['firstName'] });
|
||||
User.destroy({ truncate: true, cascade: true, force: true });
|
||||
|
||||
const user = await User.create({ firstName: 'John', lastName: 'Doe' });
|
||||
users = await User.findAll();
|
||||
|
||||
await sequelize.close();
|
||||
} catch (error) {
|
||||
console.error('Unable to connect to the database:', error);
|
||||
}
|
||||
})();
|
35
tsc1877/task1/project/admin/db_seed_local/products.js
Normal file
35
tsc1877/task1/project/admin/db_seed_local/products.js
Normal file
@@ -0,0 +1,35 @@
|
||||
const { Sequelize, DataTypes } = require('sequelize');
|
||||
|
||||
const sequelize = new Sequelize('app_db', 'db_user', 'db_user_pass', {
|
||||
host: 'mysql',
|
||||
port: 3306,
|
||||
dialect: 'mysql',
|
||||
});
|
||||
|
||||
const Product = sequelize.define(
|
||||
'Products',
|
||||
{
|
||||
pid: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true, unique: true },
|
||||
cid: { type: DataTypes.INTEGER, allowNull: false },
|
||||
name: { type: DataTypes.STRING, allowNull: false },
|
||||
description: { type: DataTypes.STRING, allowNull: false },
|
||||
price: { type: DataTypes.DECIMAL, allowNull: false },
|
||||
product_image: { type: DataTypes.STRING, allowNull: true, defaultValue: '' },
|
||||
},
|
||||
{ timestamps: false },
|
||||
);
|
||||
|
||||
(async () => {
|
||||
try {
|
||||
await sequelize.authenticate();
|
||||
console.log('Connection has been established successfully.');
|
||||
|
||||
await Product.drop();
|
||||
|
||||
await sequelize.sync();
|
||||
|
||||
await sequelize.close();
|
||||
} catch (error) {
|
||||
console.error('Unable to connect to the database:', error);
|
||||
}
|
||||
})();
|
85
tsc1877/task1/project/admin/db_seed_local/products_cid_1.js
Normal file
85
tsc1877/task1/project/admin/db_seed_local/products_cid_1.js
Normal file
@@ -0,0 +1,85 @@
|
||||
const { Sequelize, DataTypes } = require('sequelize');
|
||||
|
||||
const sequelize = new Sequelize('app_db', 'db_user', 'db_user_pass', {
|
||||
host: 'mysql',
|
||||
port: 3306,
|
||||
dialect: 'mysql',
|
||||
});
|
||||
|
||||
const Product = sequelize.define(
|
||||
'Products',
|
||||
{
|
||||
pid: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true, unique: true },
|
||||
cid: { type: DataTypes.INTEGER, allowNull: false },
|
||||
name: { type: DataTypes.STRING, allowNull: false },
|
||||
product_image: { type: DataTypes.STRING, allowNull: false },
|
||||
description: { type: DataTypes.STRING, allowNull: false },
|
||||
price: { type: DataTypes.FLOAT, allowNull: false },
|
||||
},
|
||||
{ timestamps: false },
|
||||
);
|
||||
|
||||
(async () => {
|
||||
try {
|
||||
await sequelize.authenticate();
|
||||
console.log('Connection has been established successfully.');
|
||||
|
||||
// create table
|
||||
await sequelize.sync();
|
||||
|
||||
let products = [
|
||||
{
|
||||
cid: 1,
|
||||
name: 'French Baguette',
|
||||
description: 'A long, crusty loaf of French bread with a soft interior.',
|
||||
price: 5.5,
|
||||
product_image: 'BREAD1',
|
||||
},
|
||||
{
|
||||
cid: 1,
|
||||
name: 'Whole Wheat Bread',
|
||||
description: 'A nutritious bread made with whole wheat flour and grains.',
|
||||
price: 6.5,
|
||||
product_image: 'BREAD2',
|
||||
},
|
||||
{
|
||||
cid: 1,
|
||||
name: 'Croissants',
|
||||
description: 'Buttery, flaky pastries often enjoyed with coffee or tea.',
|
||||
price: 8.5,
|
||||
product_image: 'BREAD3',
|
||||
},
|
||||
{
|
||||
cid: 1,
|
||||
name: 'Donuts',
|
||||
description: 'Sweet, fried pastries with a variety of toppings and fillings.',
|
||||
price: 4.95,
|
||||
product_image: 'BREAD4',
|
||||
},
|
||||
{
|
||||
cid: 1,
|
||||
name: 'Whole Wheat Bread',
|
||||
description: 'A nutritious bread made with whole wheat flour and grains.',
|
||||
price: 6.5,
|
||||
product_image: 'BREAD2',
|
||||
},
|
||||
{
|
||||
cid: 1,
|
||||
name: 'Croissants',
|
||||
description: 'Buttery, flaky pastries often enjoyed with coffee or tea.',
|
||||
price: 8.5,
|
||||
product_image: 'BREAD3',
|
||||
},
|
||||
];
|
||||
|
||||
for (var i = 0; i < products.length; i++) {
|
||||
await Product.create(products[i]);
|
||||
}
|
||||
|
||||
const categories = await Product.findAll();
|
||||
|
||||
await sequelize.close();
|
||||
} catch (error) {
|
||||
console.error('Unable to connect to the database:', error);
|
||||
}
|
||||
})();
|
71
tsc1877/task1/project/admin/db_seed_local/products_cid_2.js
Normal file
71
tsc1877/task1/project/admin/db_seed_local/products_cid_2.js
Normal file
@@ -0,0 +1,71 @@
|
||||
const { Sequelize, DataTypes } = require('sequelize');
|
||||
|
||||
const sequelize = new Sequelize('app_db', 'db_user', 'db_user_pass', {
|
||||
host: 'mysql',
|
||||
port: 3306,
|
||||
dialect: 'mysql',
|
||||
});
|
||||
|
||||
const Product = sequelize.define(
|
||||
'Products',
|
||||
{
|
||||
pid: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true, unique: true },
|
||||
cid: { type: DataTypes.INTEGER, allowNull: false },
|
||||
name: { type: DataTypes.STRING, allowNull: false },
|
||||
description: { type: DataTypes.STRING, allowNull: false },
|
||||
price: { type: DataTypes.DECIMAL, allowNull: false },
|
||||
product_image: { type: DataTypes.STRING, allowNull: false },
|
||||
},
|
||||
{ timestamps: false },
|
||||
);
|
||||
|
||||
(async () => {
|
||||
try {
|
||||
await sequelize.authenticate();
|
||||
console.log('Connection has been established successfully.');
|
||||
|
||||
// create table
|
||||
await sequelize.sync();
|
||||
|
||||
let products = [
|
||||
{
|
||||
cid: 2,
|
||||
name: 'Milk',
|
||||
description: 'A nutritious beverage made from the milk of cows, goats, or other mammals.',
|
||||
price: 5.5,
|
||||
product_image: 'DAIRY_1',
|
||||
},
|
||||
{
|
||||
cid: 2,
|
||||
name: 'Cheese',
|
||||
description: 'A versatile dairy product made from milk, available in a variety of flavors and textures.',
|
||||
price: 6.5,
|
||||
product_image: 'DAIRY_2',
|
||||
},
|
||||
{
|
||||
cid: 2,
|
||||
name: 'Yogurt',
|
||||
description: 'A creamy, fermented dairy product that comes in many flavors and styles.',
|
||||
price: 8.5,
|
||||
product_image: 'DAIRY_3',
|
||||
},
|
||||
{
|
||||
cid: 2,
|
||||
name: 'Butter',
|
||||
description: 'A dairy product made by churning cream, used for cooking and baking.',
|
||||
price: 4.95,
|
||||
product_image: 'DAIRY_4',
|
||||
},
|
||||
];
|
||||
|
||||
for (var i = 0; i < products.length; i++) {
|
||||
await Product.create(products[i]);
|
||||
}
|
||||
|
||||
const categories = await Product.findAll();
|
||||
|
||||
await sequelize.close();
|
||||
} catch (error) {
|
||||
console.error('Unable to connect to the database:', error);
|
||||
}
|
||||
})();
|
71
tsc1877/task1/project/admin/db_seed_local/products_cid_3.js
Normal file
71
tsc1877/task1/project/admin/db_seed_local/products_cid_3.js
Normal file
@@ -0,0 +1,71 @@
|
||||
const { Sequelize, DataTypes } = require('sequelize');
|
||||
|
||||
const sequelize = new Sequelize('app_db', 'db_user', 'db_user_pass', {
|
||||
host: 'mysql',
|
||||
port: 3306,
|
||||
dialect: 'mysql',
|
||||
});
|
||||
|
||||
const Product = sequelize.define(
|
||||
'Products',
|
||||
{
|
||||
pid: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true, unique: true },
|
||||
cid: { type: DataTypes.INTEGER, allowNull: false },
|
||||
name: { type: DataTypes.STRING, allowNull: false },
|
||||
description: { type: DataTypes.STRING, allowNull: false },
|
||||
price: { type: DataTypes.DECIMAL, allowNull: false },
|
||||
product_image: { type: DataTypes.STRING, allowNull: true, defaultValue: '' },
|
||||
},
|
||||
{ timestamps: false },
|
||||
);
|
||||
|
||||
(async () => {
|
||||
try {
|
||||
await sequelize.authenticate();
|
||||
console.log('Connection has been established successfully.');
|
||||
|
||||
// create table
|
||||
await sequelize.sync();
|
||||
|
||||
let products = [
|
||||
{
|
||||
cid: 3,
|
||||
name: 'Chicken',
|
||||
description: 'A versatile and popular type of poultry, available in many cuts and preparations.',
|
||||
price: 9.95,
|
||||
product_image: 'MEAT1',
|
||||
},
|
||||
{
|
||||
cid: 3,
|
||||
name: 'Beef',
|
||||
description: 'A type of red meat that comes from cows, available in a variety of cuts and grades.',
|
||||
price: 13.5,
|
||||
product_image: 'MEAT2',
|
||||
},
|
||||
{
|
||||
cid: 3,
|
||||
name: 'Pork',
|
||||
description: 'A type of meat that comes from pigs, available in many cuts and preparations.',
|
||||
price: 27.8,
|
||||
product_image: 'MEAT3',
|
||||
},
|
||||
{
|
||||
cid: 3,
|
||||
name: 'Lamb',
|
||||
description: 'A type of red meat that comes from sheep, available in many cuts and preparations.',
|
||||
price: 25.95,
|
||||
product_image: 'MEAT4',
|
||||
},
|
||||
];
|
||||
|
||||
for (var i = 0; i < products.length; i++) {
|
||||
await Product.create(products[i]);
|
||||
}
|
||||
|
||||
const categories = await Product.findAll();
|
||||
|
||||
await sequelize.close();
|
||||
} catch (error) {
|
||||
console.error('Unable to connect to the database:', error);
|
||||
}
|
||||
})();
|
71
tsc1877/task1/project/admin/db_seed_local/products_cid_4.js
Normal file
71
tsc1877/task1/project/admin/db_seed_local/products_cid_4.js
Normal file
@@ -0,0 +1,71 @@
|
||||
const { Sequelize, DataTypes } = require('sequelize');
|
||||
|
||||
const sequelize = new Sequelize('app_db', 'db_user', 'db_user_pass', {
|
||||
host: 'mysql',
|
||||
port: 3306,
|
||||
dialect: 'mysql',
|
||||
});
|
||||
|
||||
const Product = sequelize.define(
|
||||
'Products',
|
||||
{
|
||||
pid: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true, unique: true },
|
||||
cid: { type: DataTypes.INTEGER, allowNull: false },
|
||||
name: { type: DataTypes.STRING, allowNull: false },
|
||||
description: { type: DataTypes.STRING, allowNull: false },
|
||||
price: { type: DataTypes.DECIMAL, allowNull: false },
|
||||
product_image: { type: DataTypes.STRING, allowNull: false },
|
||||
},
|
||||
{ timestamps: false },
|
||||
);
|
||||
|
||||
(async () => {
|
||||
try {
|
||||
await sequelize.authenticate();
|
||||
console.log('Connection has been established successfully.');
|
||||
|
||||
// create table
|
||||
await sequelize.sync();
|
||||
|
||||
let products = [
|
||||
{
|
||||
cid: 4,
|
||||
name: 'Sliced Meats',
|
||||
description: 'Deli meats such as ham, turkey, salami, and roast beef, sliced to order.',
|
||||
price: 6.95,
|
||||
product_image: 'DELI_1',
|
||||
},
|
||||
{
|
||||
cid: 4,
|
||||
name: 'Cheese',
|
||||
description: 'A variety of cheeses, such as cheddar, Swiss, and mozzarella, sliced to order.',
|
||||
price: 7.5,
|
||||
product_image: 'DELI_2',
|
||||
},
|
||||
{
|
||||
cid: 4,
|
||||
name: 'Prepared Salads',
|
||||
description: 'Salads such as pasta salad, potato salad, and coleslaw, made fresh in-store.',
|
||||
price: 8.5,
|
||||
product_image: 'DELI_3',
|
||||
},
|
||||
{
|
||||
cid: 4,
|
||||
name: 'Rotisserie Chicken',
|
||||
description: 'Whole chickens that have been seasoned and roasted in-store, ready to take home and serve.',
|
||||
price: 7.5,
|
||||
product_image: 'DELI_4',
|
||||
},
|
||||
];
|
||||
|
||||
for (var i = 0; i < products.length; i++) {
|
||||
await Product.create(products[i]);
|
||||
}
|
||||
|
||||
const categories = await Product.findAll();
|
||||
|
||||
await sequelize.close();
|
||||
} catch (error) {
|
||||
console.error('Unable to connect to the database:', error);
|
||||
}
|
||||
})();
|
74
tsc1877/task1/project/admin/db_seed_local/products_cid_5.js
Normal file
74
tsc1877/task1/project/admin/db_seed_local/products_cid_5.js
Normal file
@@ -0,0 +1,74 @@
|
||||
const { Sequelize, DataTypes } = require('sequelize');
|
||||
|
||||
const sequelize = new Sequelize('app_db', 'db_user', 'db_user_pass', {
|
||||
host: 'mysql',
|
||||
port: 3306,
|
||||
dialect: 'mysql',
|
||||
});
|
||||
|
||||
const Product = sequelize.define(
|
||||
'Products',
|
||||
{
|
||||
pid: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true, unique: true },
|
||||
cid: { type: DataTypes.INTEGER, allowNull: false },
|
||||
name: { type: DataTypes.STRING, allowNull: false },
|
||||
product_image: { type: DataTypes.STRING, allowNull: false },
|
||||
description: { type: DataTypes.STRING, allowNull: false },
|
||||
price: { type: DataTypes.DECIMAL, allowNull: false },
|
||||
},
|
||||
{ timestamps: false },
|
||||
);
|
||||
|
||||
(async () => {
|
||||
try {
|
||||
await sequelize.authenticate();
|
||||
console.log('Connection has been established successfully.');
|
||||
|
||||
// create table
|
||||
await sequelize.sync();
|
||||
|
||||
let products = [
|
||||
{
|
||||
cid: 5,
|
||||
name: 'Frozen Vegetables',
|
||||
description: 'A variety of vegetables, such as peas, corn, and broccoli, frozen at peak freshness.',
|
||||
price: 5.5,
|
||||
product_image: 'FROZEN_1',
|
||||
},
|
||||
{
|
||||
cid: 5,
|
||||
name: 'Frozen Seafood',
|
||||
description: 'A variety of seafood, such as shrimp, fish, and scallops, frozen for freshness and convenience.',
|
||||
|
||||
price: 6.5,
|
||||
product_image: 'FROZEN_2',
|
||||
},
|
||||
{
|
||||
cid: 5,
|
||||
name: 'Frozen Meals',
|
||||
description: 'Pre-made meals such as pizza, lasagna, and stir-fry, available for quick and easy dinners.',
|
||||
|
||||
price: 8.5,
|
||||
product_image: 'FROZEN_3',
|
||||
},
|
||||
{
|
||||
cid: 5,
|
||||
name: 'Frozen Fruits',
|
||||
description: 'A variety of fruits, such as berries, mango, and pineapple, frozen at peak freshness.',
|
||||
|
||||
price: 4.95,
|
||||
product_image: 'FROZEN_4',
|
||||
},
|
||||
];
|
||||
|
||||
for (var i = 0; i < products.length; i++) {
|
||||
await Product.create(products[i]);
|
||||
}
|
||||
|
||||
const categories = await Product.findAll();
|
||||
|
||||
await sequelize.close();
|
||||
} catch (error) {
|
||||
console.error('Unable to connect to the database:', error);
|
||||
}
|
||||
})();
|
85
tsc1877/task1/project/admin/db_seed_local/products_cid_6.js
Normal file
85
tsc1877/task1/project/admin/db_seed_local/products_cid_6.js
Normal file
@@ -0,0 +1,85 @@
|
||||
const { Sequelize, DataTypes } = require('sequelize');
|
||||
|
||||
const sequelize = new Sequelize('app_db', 'db_user', 'db_user_pass', {
|
||||
host: 'mysql',
|
||||
port: 3306,
|
||||
dialect: 'mysql',
|
||||
});
|
||||
|
||||
const Product = sequelize.define(
|
||||
'Products',
|
||||
{
|
||||
pid: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true, unique: true },
|
||||
cid: { type: DataTypes.INTEGER, allowNull: false },
|
||||
name: { type: DataTypes.STRING, allowNull: false },
|
||||
product_image: { type: DataTypes.STRING, allowNull: false },
|
||||
description: { type: DataTypes.STRING, allowNull: false },
|
||||
price: { type: DataTypes.DECIMAL, allowNull: false },
|
||||
},
|
||||
{ timestamps: false },
|
||||
);
|
||||
|
||||
(async () => {
|
||||
try {
|
||||
await sequelize.authenticate();
|
||||
console.log('Connection has been established successfully.');
|
||||
|
||||
// create table
|
||||
await sequelize.sync();
|
||||
|
||||
let products = [
|
||||
{
|
||||
cid: 6,
|
||||
name: 'Pasta',
|
||||
description: 'A variety of pasta shapes and types, such as spaghetti, macaroni, and lasagna noodles.',
|
||||
price: 5.5,
|
||||
product_image: 'PANTRY_1',
|
||||
},
|
||||
{
|
||||
cid: 6,
|
||||
name: 'Rice',
|
||||
description: 'A variety of rice types, such as white rice, brown rice, and jasmine rice.',
|
||||
price: 6.5,
|
||||
product_image: 'PANTRY_2',
|
||||
},
|
||||
{
|
||||
cid: 6,
|
||||
name: 'Canned Beans',
|
||||
description: 'A variety of beans, such as black beans, kidney beans, and chickpeas, canned for convenience.',
|
||||
price: 8.5,
|
||||
product_image: 'PANTRY_3',
|
||||
},
|
||||
{
|
||||
cid: 6,
|
||||
name: 'Canned Tomatoes',
|
||||
description: 'A variety of canned tomatoes, such as diced tomatoes, crushed tomatoes, and tomato sauce.',
|
||||
price: 4.95,
|
||||
product_image: 'PANTRY_4',
|
||||
},
|
||||
{
|
||||
cid: 6,
|
||||
name: 'Canned Beans',
|
||||
description: 'A variety of beans, such as black beans, kidney beans, and chickpeas, canned for convenience.',
|
||||
price: 8.5,
|
||||
product_image: 'PANTRY_3',
|
||||
},
|
||||
{
|
||||
cid: 6,
|
||||
name: 'Canned Tomatoes',
|
||||
description: 'A variety of canned tomatoes, such as diced tomatoes, crushed tomatoes, and tomato sauce.',
|
||||
price: 4.95,
|
||||
product_image: 'PANTRY_4',
|
||||
},
|
||||
];
|
||||
|
||||
for (var i = 0; i < products.length; i++) {
|
||||
await Product.create(products[i]);
|
||||
}
|
||||
|
||||
const categories = await Product.findAll();
|
||||
|
||||
await sequelize.close();
|
||||
} catch (error) {
|
||||
console.error('Unable to connect to the database:', error);
|
||||
}
|
||||
})();
|
77
tsc1877/task1/project/admin/db_seed_local/products_cid_7.js
Normal file
77
tsc1877/task1/project/admin/db_seed_local/products_cid_7.js
Normal file
@@ -0,0 +1,77 @@
|
||||
const { Sequelize, DataTypes } = require('sequelize');
|
||||
|
||||
const sequelize = new Sequelize('app_db', 'db_user', 'db_user_pass', {
|
||||
host: 'mysql',
|
||||
port: 3306,
|
||||
dialect: 'mysql',
|
||||
});
|
||||
|
||||
const Product = sequelize.define(
|
||||
'Products',
|
||||
{
|
||||
pid: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true, unique: true },
|
||||
cid: { type: DataTypes.INTEGER, allowNull: false },
|
||||
name: { type: DataTypes.STRING, allowNull: false },
|
||||
description: { type: DataTypes.STRING, allowNull: false },
|
||||
price: { type: DataTypes.DECIMAL, allowNull: false },
|
||||
},
|
||||
{ timestamps: false },
|
||||
);
|
||||
|
||||
(async () => {
|
||||
try {
|
||||
await sequelize.authenticate();
|
||||
console.log('Connection has been established successfully.');
|
||||
|
||||
// create table
|
||||
await sequelize.sync();
|
||||
|
||||
let products = [
|
||||
{
|
||||
cid: 7,
|
||||
name: 'Organic Cold Brew Coffee',
|
||||
description: 'Rich cold brew coffee crafted with organic fair trade arabica beans.',
|
||||
price: 3.5,
|
||||
product_image: 'BREAD1',
|
||||
},
|
||||
{
|
||||
cid: 7,
|
||||
name: 'Strawberry Banana Smoothie',
|
||||
description: 'Blended smoothie combining fresh strawberries and bananas with yogurt.',
|
||||
price: 4.5,
|
||||
product_image: 'BREAD2',
|
||||
},
|
||||
{
|
||||
cid: 7,
|
||||
name: 'Matcha Green Tea Latte',
|
||||
description: 'Warm frothy latte infused with antioxcidan7-rich Japanese green tea powder.',
|
||||
price: 4.95,
|
||||
product_image: 'BREAD3',
|
||||
},
|
||||
{
|
||||
cid: 7,
|
||||
name: 'Iced Passionfruit Black Tea Lemonade',
|
||||
description: 'Refreshing summertime drink blending passionfruit, black tea, and lemonade.',
|
||||
price: 3.95,
|
||||
product_image: 'BREAD4',
|
||||
},
|
||||
{
|
||||
cid: 7,
|
||||
name: 'Espresso Con Panna',
|
||||
description: 'Double shot espresso topped with whipped cream.',
|
||||
price: 3.95,
|
||||
product_image: 'BREAD5',
|
||||
},
|
||||
];
|
||||
|
||||
for (var i = 0; i < products.length; i++) {
|
||||
await Product.create(products[i]);
|
||||
}
|
||||
|
||||
const categories = await Product.findAll();
|
||||
|
||||
await sequelize.close();
|
||||
} catch (error) {
|
||||
console.error('Unable to connect to the database:', error);
|
||||
}
|
||||
})();
|
27
tsc1877/task1/project/admin/db_seed_local/seed_all.js
Normal file
27
tsc1877/task1/project/admin/db_seed_local/seed_all.js
Normal file
@@ -0,0 +1,27 @@
|
||||
function delay(time_ms) {
|
||||
return new Promise((res, rej) => {
|
||||
setTimeout(() => {
|
||||
res();
|
||||
}, time_ms);
|
||||
});
|
||||
}
|
||||
|
||||
(async () => {
|
||||
await require('./helloworld');
|
||||
await delay(1000);
|
||||
await require('./categories');
|
||||
await delay(1000);
|
||||
|
||||
await require('./products');
|
||||
await delay(1000);
|
||||
|
||||
await require('./products_cid_1');
|
||||
await require('./products_cid_2');
|
||||
await require('./products_cid_3');
|
||||
await require('./products_cid_4');
|
||||
await require('./products_cid_5');
|
||||
await require('./products_cid_6');
|
||||
// await require('./products_cid_7');
|
||||
|
||||
console.log('done');
|
||||
})();
|
8
tsc1877/task1/project/admin/dev.bat
Normal file
8
tsc1877/task1/project/admin/dev.bat
Normal file
@@ -0,0 +1,8 @@
|
||||
rmdir /s /q .next
|
||||
|
||||
call yarn
|
||||
call yarn build
|
||||
|
||||
call node ./db_seed/seed_all.js
|
||||
|
||||
yarn dev
|
9
tsc1877/task1/project/admin/entry.sh
Executable file
9
tsc1877/task1/project/admin/entry.sh
Executable file
@@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -ex
|
||||
|
||||
# loop forever
|
||||
while true
|
||||
do
|
||||
yarn start
|
||||
done
|
8
tsc1877/task1/project/admin/jsconfig.json
Normal file
8
tsc1877/task1/project/admin/jsconfig.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"baseUrl": "."
|
||||
},
|
||||
"include": [
|
||||
"src"
|
||||
]
|
||||
}
|
6
tsc1877/task1/project/admin/next-env.d.ts
vendored
Normal file
6
tsc1877/task1/project/admin/next-env.d.ts
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
/// <reference types="next" />
|
||||
/// <reference types="next/types/global" />
|
||||
/// <reference types="next/image-types/global" />
|
||||
|
||||
// NOTE: This file should not be edited
|
||||
// see https://nextjs.org/docs/basic-features/typescript for more information.
|
18
tsc1877/task1/project/admin/next.config.js
Normal file
18
tsc1877/task1/project/admin/next.config.js
Normal file
@@ -0,0 +1,18 @@
|
||||
const path = require('path');
|
||||
|
||||
module.exports = {
|
||||
trailingSlash: true,
|
||||
reactStrictMode: false,
|
||||
experimental: {
|
||||
esmExternals: false,
|
||||
jsconfigPaths: true, // enables it for both jsconfig.json and tsconfig.json
|
||||
},
|
||||
webpack: config => {
|
||||
config.resolve.alias = {
|
||||
...config.resolve.alias,
|
||||
apexcharts: path.resolve(__dirname, './node_modules/apexcharts-clevision'),
|
||||
};
|
||||
|
||||
return config;
|
||||
},
|
||||
};
|
93
tsc1877/task1/project/admin/package.json
Normal file
93
tsc1877/task1/project/admin/package.json
Normal file
@@ -0,0 +1,93 @@
|
||||
{
|
||||
"name": "materio-mui-react-nextjs-admin-template-free",
|
||||
"description": "Most Powerful & Comprehensive Free MUI React NextJS Admin Dashboard Template built for developers! 🚀",
|
||||
"license": "MIT",
|
||||
"version": "1.0.0",
|
||||
"author": {
|
||||
"name": "ThemeSelection",
|
||||
"url": "https://themeselection.com/"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/themeselection/materio-mui-react-nextjs-admin-template-free/issues"
|
||||
},
|
||||
"private": false,
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/themeselection/materio-mui-react-nextjs-admin-template-free.git"
|
||||
},
|
||||
"homepage": "https://themeselection.com/products/materio-free-mui-react-nextjs-admin-template/",
|
||||
"keywords": [
|
||||
"react",
|
||||
"javascript",
|
||||
"admin",
|
||||
"typescript",
|
||||
"dashboard",
|
||||
"material-design",
|
||||
"nextjs",
|
||||
"material-ui",
|
||||
"admin-dashboard",
|
||||
"free",
|
||||
"mui",
|
||||
"admin-template",
|
||||
"admin-panel",
|
||||
"freebies",
|
||||
"nextjs-template",
|
||||
"react-dashboard",
|
||||
"themeselection"
|
||||
],
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
"build": "next build",
|
||||
"start": "next start",
|
||||
"export": "next export",
|
||||
"lint": "eslint --fix \"src/**/*.{js,jsx}\"",
|
||||
"format": "prettier --write \"src/**/*.{js,jsx}\""
|
||||
},
|
||||
"dependencies": {
|
||||
"@emotion/cache": "^11.6.0",
|
||||
"@emotion/react": "^11.7.0",
|
||||
"@emotion/server": "^11.4.0",
|
||||
"@emotion/styled": "^11.6.0",
|
||||
"@mui/icons-material": "^5.15.14",
|
||||
"@mui/lab": "^5.0.0-alpha.70",
|
||||
"@mui/material": "^5.4.3",
|
||||
"@paypal/react-paypal-js": "^8.2.0",
|
||||
"@popperjs/core": "^2.11.2",
|
||||
"apexcharts-clevision": "3.28.5",
|
||||
"axios": "^1.6.8",
|
||||
"babel-eslint": "^10.1.0",
|
||||
"bcrypt": "^5.1.1",
|
||||
"clsx": "^1.1.1",
|
||||
"crypto": "^1.0.1",
|
||||
"crypto-js": "^4.2.0",
|
||||
"dotenv": "^16.4.5",
|
||||
"eslint-plugin-react": "^7.29.4",
|
||||
"formidable": "^3.5.1",
|
||||
"formik": "^2.4.5",
|
||||
"fs-extra": "^11.2.0",
|
||||
"mdi-material-ui": "^7.1.0",
|
||||
"mysql2": "^3.9.3",
|
||||
"next": "12.0.4",
|
||||
"next-csrf": "^0.2.1",
|
||||
"nprogress": "^0.2.0",
|
||||
"randomatic": "^3.1.1",
|
||||
"react": "17.0.2",
|
||||
"react-apexcharts": "^1.3.9",
|
||||
"react-datepicker": "^4.5.0",
|
||||
"react-dom": "17.0.2",
|
||||
"react-dropzone": "^14.2.3",
|
||||
"react-horizontal-scrolling-menu": "^7.0.0",
|
||||
"react-perfect-scrollbar": "^1.5.8",
|
||||
"react-popper": "^2.2.5",
|
||||
"sequelize": "^6.37.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"eslint": "^7.32.0",
|
||||
"eslint-config-next": "12.0.4",
|
||||
"eslint-config-prettier": "^8.3.0",
|
||||
"eslint-import-resolver-alias": "^1.1.2",
|
||||
"eslint-import-resolver-typescript": "^2.5.0",
|
||||
"eslint-plugin-import": "^2.25.4",
|
||||
"next-transpile-modules": "^9.0.0"
|
||||
}
|
||||
}
|
BIN
tsc1877/task1/project/admin/public/images/apple-touch-icon.png
(Stored with Git LFS)
Normal file
BIN
tsc1877/task1/project/admin/public/images/apple-touch-icon.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
tsc1877/task1/project/admin/public/images/avatars/1.png
(Stored with Git LFS)
Normal file
BIN
tsc1877/task1/project/admin/public/images/avatars/1.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
tsc1877/task1/project/admin/public/images/avatars/2.png
(Stored with Git LFS)
Normal file
BIN
tsc1877/task1/project/admin/public/images/avatars/2.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
tsc1877/task1/project/admin/public/images/avatars/3.png
(Stored with Git LFS)
Normal file
BIN
tsc1877/task1/project/admin/public/images/avatars/3.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
tsc1877/task1/project/admin/public/images/avatars/4.png
(Stored with Git LFS)
Normal file
BIN
tsc1877/task1/project/admin/public/images/avatars/4.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
tsc1877/task1/project/admin/public/images/avatars/5.png
(Stored with Git LFS)
Normal file
BIN
tsc1877/task1/project/admin/public/images/avatars/5.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
tsc1877/task1/project/admin/public/images/avatars/6.png
(Stored with Git LFS)
Normal file
BIN
tsc1877/task1/project/admin/public/images/avatars/6.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
tsc1877/task1/project/admin/public/images/avatars/7.png
(Stored with Git LFS)
Normal file
BIN
tsc1877/task1/project/admin/public/images/avatars/7.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
tsc1877/task1/project/admin/public/images/avatars/8.png
(Stored with Git LFS)
Normal file
BIN
tsc1877/task1/project/admin/public/images/avatars/8.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
tsc1877/task1/project/admin/public/images/cards/analog-clock.jpg
(Stored with Git LFS)
Normal file
BIN
tsc1877/task1/project/admin/public/images/cards/analog-clock.jpg
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
tsc1877/task1/project/admin/public/images/cards/background-user.png
(Stored with Git LFS)
Normal file
BIN
tsc1877/task1/project/admin/public/images/cards/background-user.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
tsc1877/task1/project/admin/public/images/cards/glass-house.png
(Stored with Git LFS)
Normal file
BIN
tsc1877/task1/project/admin/public/images/cards/glass-house.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
tsc1877/task1/project/admin/public/images/cards/iPhone-11-pro.png
(Stored with Git LFS)
Normal file
BIN
tsc1877/task1/project/admin/public/images/cards/iPhone-11-pro.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
tsc1877/task1/project/admin/public/images/cards/logo-aviato.png
(Stored with Git LFS)
Normal file
BIN
tsc1877/task1/project/admin/public/images/cards/logo-aviato.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
tsc1877/task1/project/admin/public/images/cards/logo-bitbank.png
(Stored with Git LFS)
Normal file
BIN
tsc1877/task1/project/admin/public/images/cards/logo-bitbank.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
tsc1877/task1/project/admin/public/images/cards/logo-zipcar.png
(Stored with Git LFS)
Normal file
BIN
tsc1877/task1/project/admin/public/images/cards/logo-zipcar.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
tsc1877/task1/project/admin/public/images/cards/paper-boat.png
(Stored with Git LFS)
Normal file
BIN
tsc1877/task1/project/admin/public/images/cards/paper-boat.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
tsc1877/task1/project/admin/public/images/cards/paypal.png
(Stored with Git LFS)
Normal file
BIN
tsc1877/task1/project/admin/public/images/cards/paypal.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
tsc1877/task1/project/admin/public/images/cards/samsung.webp
Normal file
BIN
tsc1877/task1/project/admin/public/images/cards/samsung.webp
Normal file
Binary file not shown.
After Width: | Height: | Size: 23 KiB |
BIN
tsc1877/task1/project/admin/public/images/cards/vision_pro.webp
Normal file
BIN
tsc1877/task1/project/admin/public/images/cards/vision_pro.webp
Normal file
Binary file not shown.
After Width: | Height: | Size: 11 KiB |
BIN
tsc1877/task1/project/admin/public/images/cards/watch-on-hand.jpg
(Stored with Git LFS)
Normal file
BIN
tsc1877/task1/project/admin/public/images/cards/watch-on-hand.jpg
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
tsc1877/task1/project/admin/public/images/favicon.png
(Stored with Git LFS)
Normal file
BIN
tsc1877/task1/project/admin/public/images/favicon.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
tsc1877/task1/project/admin/public/images/logos/american-bank.png
(Stored with Git LFS)
Normal file
BIN
tsc1877/task1/project/admin/public/images/logos/american-bank.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
tsc1877/task1/project/admin/public/images/logos/aws.png
(Stored with Git LFS)
Normal file
BIN
tsc1877/task1/project/admin/public/images/logos/aws.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
tsc1877/task1/project/admin/public/images/logos/citi-bank.png
(Stored with Git LFS)
Normal file
BIN
tsc1877/task1/project/admin/public/images/logos/citi-bank.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
tsc1877/task1/project/admin/public/images/logos/digital-ocean.png
(Stored with Git LFS)
Normal file
BIN
tsc1877/task1/project/admin/public/images/logos/digital-ocean.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
tsc1877/task1/project/admin/public/images/logos/github.png
(Stored with Git LFS)
Normal file
BIN
tsc1877/task1/project/admin/public/images/logos/github.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
tsc1877/task1/project/admin/public/images/logos/google.png
(Stored with Git LFS)
Normal file
BIN
tsc1877/task1/project/admin/public/images/logos/google.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
tsc1877/task1/project/admin/public/images/logos/gumroad.png
(Stored with Git LFS)
Normal file
BIN
tsc1877/task1/project/admin/public/images/logos/gumroad.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
tsc1877/task1/project/admin/public/images/logos/mastercard-label.png
(Stored with Git LFS)
Normal file
BIN
tsc1877/task1/project/admin/public/images/logos/mastercard-label.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
tsc1877/task1/project/admin/public/images/logos/slack.png
(Stored with Git LFS)
Normal file
BIN
tsc1877/task1/project/admin/public/images/logos/slack.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
tsc1877/task1/project/admin/public/images/logos/stripe.png
(Stored with Git LFS)
Normal file
BIN
tsc1877/task1/project/admin/public/images/logos/stripe.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
tsc1877/task1/project/admin/public/images/misc/chart.png
(Stored with Git LFS)
Normal file
BIN
tsc1877/task1/project/admin/public/images/misc/chart.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
tsc1877/task1/project/admin/public/images/misc/materio-pro-banner.png
(Stored with Git LFS)
Normal file
BIN
tsc1877/task1/project/admin/public/images/misc/materio-pro-banner.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
tsc1877/task1/project/admin/public/images/misc/paypal.png
(Stored with Git LFS)
Normal file
BIN
tsc1877/task1/project/admin/public/images/misc/paypal.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
tsc1877/task1/project/admin/public/images/misc/triangle-dark.png
(Stored with Git LFS)
Normal file
BIN
tsc1877/task1/project/admin/public/images/misc/triangle-dark.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
tsc1877/task1/project/admin/public/images/misc/triangle-light.png
(Stored with Git LFS)
Normal file
BIN
tsc1877/task1/project/admin/public/images/misc/triangle-light.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
tsc1877/task1/project/admin/public/images/misc/trophy.png
(Stored with Git LFS)
Normal file
BIN
tsc1877/task1/project/admin/public/images/misc/trophy.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
tsc1877/task1/project/admin/public/images/misc/upgrade-banner-dark.png
(Stored with Git LFS)
Normal file
BIN
tsc1877/task1/project/admin/public/images/misc/upgrade-banner-dark.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
tsc1877/task1/project/admin/public/images/misc/upgrade-banner-light.png
(Stored with Git LFS)
Normal file
BIN
tsc1877/task1/project/admin/public/images/misc/upgrade-banner-light.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
tsc1877/task1/project/admin/public/images/pages/401.png
(Stored with Git LFS)
Normal file
BIN
tsc1877/task1/project/admin/public/images/pages/401.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
tsc1877/task1/project/admin/public/images/pages/404.png
(Stored with Git LFS)
Normal file
BIN
tsc1877/task1/project/admin/public/images/pages/404.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
tsc1877/task1/project/admin/public/images/pages/500.png
(Stored with Git LFS)
Normal file
BIN
tsc1877/task1/project/admin/public/images/pages/500.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
tsc1877/task1/project/admin/public/images/pages/auth-v1-mask-dark.png
(Stored with Git LFS)
Normal file
BIN
tsc1877/task1/project/admin/public/images/pages/auth-v1-mask-dark.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
tsc1877/task1/project/admin/public/images/pages/auth-v1-mask-light.png
(Stored with Git LFS)
Normal file
BIN
tsc1877/task1/project/admin/public/images/pages/auth-v1-mask-light.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
tsc1877/task1/project/admin/public/images/pages/auth-v1-tree-2.png
(Stored with Git LFS)
Normal file
BIN
tsc1877/task1/project/admin/public/images/pages/auth-v1-tree-2.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
tsc1877/task1/project/admin/public/images/pages/auth-v1-tree.png
(Stored with Git LFS)
Normal file
BIN
tsc1877/task1/project/admin/public/images/pages/auth-v1-tree.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
tsc1877/task1/project/admin/public/images/pages/misc-mask-dark.png
(Stored with Git LFS)
Normal file
BIN
tsc1877/task1/project/admin/public/images/pages/misc-mask-dark.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
tsc1877/task1/project/admin/public/images/pages/misc-mask-light.png
(Stored with Git LFS)
Normal file
BIN
tsc1877/task1/project/admin/public/images/pages/misc-mask-light.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
tsc1877/task1/project/admin/public/images/pages/pose-m-1.png
(Stored with Git LFS)
Normal file
BIN
tsc1877/task1/project/admin/public/images/pages/pose-m-1.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
tsc1877/task1/project/admin/public/images/pages/tree-2.png
(Stored with Git LFS)
Normal file
BIN
tsc1877/task1/project/admin/public/images/pages/tree-2.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
tsc1877/task1/project/admin/public/images/pages/tree-3.png
(Stored with Git LFS)
Normal file
BIN
tsc1877/task1/project/admin/public/images/pages/tree-3.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
tsc1877/task1/project/admin/public/images/pages/tree.png
(Stored with Git LFS)
Normal file
BIN
tsc1877/task1/project/admin/public/images/pages/tree.png
(Stored with Git LFS)
Normal file
Binary file not shown.
4
tsc1877/task1/project/admin/public/vercel.svg
Normal file
4
tsc1877/task1/project/admin/public/vercel.svg
Normal file
@@ -0,0 +1,4 @@
|
||||
<svg width="283" height="64" viewBox="0 0 283 64" fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M141.04 16c-11.04 0-19 7.2-19 18s8.96 18 20 18c6.67 0 12.55-2.64 16.19-7.09l-7.65-4.42c-2.02 2.21-5.09 3.5-8.54 3.5-4.79 0-8.86-2.5-10.37-6.5h28.02c.22-1.12.35-2.28.35-3.5 0-10.79-7.96-17.99-19-17.99zm-9.46 14.5c1.25-3.99 4.67-6.5 9.45-6.5 4.79 0 8.21 2.51 9.45 6.5h-18.9zM248.72 16c-11.04 0-19 7.2-19 18s8.96 18 20 18c6.67 0 12.55-2.64 16.19-7.09l-7.65-4.42c-2.02 2.21-5.09 3.5-8.54 3.5-4.79 0-8.86-2.5-10.37-6.5h28.02c.22-1.12.35-2.28.35-3.5 0-10.79-7.96-17.99-19-17.99zm-9.45 14.5c1.25-3.99 4.67-6.5 9.45-6.5 4.79 0 8.21 2.51 9.45 6.5h-18.9zM200.24 34c0 6 3.92 10 10 10 4.12 0 7.21-1.87 8.8-4.92l7.68 4.43c-3.18 5.3-9.14 8.49-16.48 8.49-11.05 0-19-7.2-19-18s7.96-18 19-18c7.34 0 13.29 3.19 16.48 8.49l-7.68 4.43c-1.59-3.05-4.68-4.92-8.8-4.92-6.07 0-10 4-10 10zm82.48-29v46h-9V5h9zM36.95 0L73.9 64H0L36.95 0zm92.38 5l-27.71 48L73.91 5H84.3l17.32 30 17.32-30h10.39zm58.91 12v9.69c-1-.29-2.06-.49-3.2-.49-5.81 0-10 4-10 10V51h-9V17h9v9.2c0-5.08 5.91-9.2 13.2-9.2z" fill="#000"/>
|
||||
</svg>
|
After Width: | Height: | Size: 1.1 KiB |
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user