Compare commits
3 Commits
c80fa5cd3c
...
930a9c6c07
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
930a9c6c07 | ||
|
|
89e730496f | ||
|
|
c8c80685ec |
@@ -1,3 +1,7 @@
|
||||
import config from './server/config.ts'
|
||||
import io from './server/lib/io.js'
|
||||
|
||||
config.ensureAllDirsAreCreated()
|
||||
io.copyDir('./client', config.dirs.WEB_PAGE_DIR)
|
||||
|
||||
await import('./server/build.ts').then(a => a.default(config.dirs.WEB_PAGE_DIR))
|
||||
|
||||
@@ -5,16 +5,16 @@
|
||||
"express": "npm:express@^4.21.2",
|
||||
"socket.io": "npm:socket.io@^4.8.1",
|
||||
// Database
|
||||
"sequelize": "npm:sequelize@^6.37.7",
|
||||
"sqlite3": "npm:sqlite3@^5.1.7",
|
||||
// Front-end Compiling
|
||||
"@babel/core": "npm:@babel/core@^7.26.10",
|
||||
"@babel/preset-env": "npm:@babel/preset-env@^7.26.9",
|
||||
"@babel/preset-react": "npm:@babel/preset-react@^7.26.3",
|
||||
"babel-minify": "npm:babel-minify@^0.5.2"
|
||||
"@babel/preset-react": "npm:@babel/preset-react@^7.26.3"
|
||||
},
|
||||
"tasks": {
|
||||
// 編譯並運行
|
||||
"run": "deno run --allow-read --allow-write --allow-import --allow-env --allow-net --allow-sys ./start-server.ts",
|
||||
// 編譯前端頁面
|
||||
"compile-webpage": "deno run --allow-read --allow-write --allow-import --allow-env ./compile-webpage.ts"
|
||||
"compile-webpage": "deno run --allow-read --allow-write --allow-import --allow-env --allow-sys ./compile-webpage.ts"
|
||||
}
|
||||
}
|
||||
4
run.sh
Normal file
4
run.sh
Normal file
@@ -0,0 +1,4 @@
|
||||
echo "主文件夾 = $HOME"
|
||||
# mkdir usr_home || true
|
||||
# HOME=./usr_home
|
||||
deno task run
|
||||
@@ -11,11 +11,7 @@ function compileJs(path: string) {
|
||||
},
|
||||
],
|
||||
"@babel/preset-react",
|
||||
[
|
||||
"minify", {
|
||||
|
||||
}
|
||||
],
|
||||
// "minify",
|
||||
],
|
||||
targets: {
|
||||
chrome: "53",
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
// @ts-types="npm:sequelize"
|
||||
import { Sequelize } from 'sequelize'
|
||||
import Config from "../config.ts"
|
||||
import User from "./User.ts";
|
||||
|
||||
abstract class BaseDataManager {
|
||||
declare sequelize: Sequelize
|
||||
declare name: string
|
||||
constructor(name: string) {
|
||||
this.init(name)
|
||||
@@ -12,10 +9,7 @@ abstract class BaseDataManager {
|
||||
}
|
||||
private init(name: string) {
|
||||
this.name = name
|
||||
this.sequelize = new Sequelize({
|
||||
dialect: 'sqlite',
|
||||
storage: Config.dirs.DATABASES_DIR + '/' + name + '.db'
|
||||
})
|
||||
|
||||
}
|
||||
abstract onInit(): void
|
||||
}
|
||||
@@ -23,7 +17,7 @@ abstract class BaseDataManager {
|
||||
class UserDataManager extends BaseDataManager {
|
||||
static SINGLE_INSTANCE = new UserDataManager('users')
|
||||
override onInit(): void {
|
||||
User.initTable(this.sequelize, this.name)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,35 +1,3 @@
|
||||
// @ts-types="npm:sequelize"
|
||||
import { Sequelize, Model, DataTypes, CreationOptional } from 'sequelize'
|
||||
|
||||
export default class User extends Model {
|
||||
declare created_id: CreationOptional<number>
|
||||
declare user_name: string | null
|
||||
declare nick_name: string | null
|
||||
declare avatar: Blob
|
||||
|
||||
static async initTable(sequelize: Sequelize, name: string) {
|
||||
this.init({
|
||||
created_id: {
|
||||
type: DataTypes.INTEGER.UNSIGNED,
|
||||
autoIncrement: true,
|
||||
primaryKey: true,
|
||||
},
|
||||
user_name: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: true,
|
||||
},
|
||||
nick_name: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: true,
|
||||
},
|
||||
avatar: {
|
||||
type: DataTypes.BLOB,
|
||||
allowNull: true,
|
||||
},
|
||||
}, {
|
||||
sequelize: sequelize,
|
||||
tableName: name,
|
||||
})
|
||||
await this.sync({ alter: true })
|
||||
}
|
||||
export default class User {
|
||||
|
||||
}
|
||||
|
||||
@@ -41,4 +41,8 @@ sio.on("connection", (socket) => {
|
||||
})
|
||||
})
|
||||
|
||||
httpApp.listen(80)
|
||||
export {
|
||||
app as expressApp,
|
||||
httpApp as httpServer,
|
||||
sio as SocketIoServer,
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import './compile-webpage.ts'
|
||||
|
||||
import {
|
||||
expressApp,
|
||||
httpServer,
|
||||
SocketIoServer,
|
||||
} from './server/http.ts'
|
||||
|
||||
httpServer.listen(8080)
|
||||
|
||||
console.log("TheWhiteSilk server started successfully")
|
||||
|
||||
Reference in New Issue
Block a user