Skip to content

Commit a301121

Browse files
author
Aashutosh
committed
complete collaboratice code editor demo project
0 parents  commit a301121

40 files changed

+5705
-0
lines changed

.config/dbConn.js

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
2+
const {Pool}=require('pg');
3+
const { DB_HOST, DB_USER, DB_NAME, DB_PASSWORD, DB_PORT, SSL_CA, SSL_KEY, SSL_CERT } = require('../config');
4+
const options=require('../server')
5+
6+
const fs=require('fs');
7+
8+
//cockroachDB
9+
// const connectionString=process.env.DATABASE_URL;
10+
11+
// const pool = new Pool({
12+
// connectionString,
13+
// application_name:"collaborative_code_editor",
14+
// ssl: {
15+
// rejectUnauthorized: false
16+
// }
17+
// });
18+
19+
const pool = new Pool({
20+
user: DB_USER,
21+
host: DB_HOST,
22+
database: DB_NAME,
23+
password: DB_PASSWORD,
24+
port: DB_PORT,
25+
ssl:{ // certificate authentication for user "zuru problem"
26+
rejectUnauthorized:false,
27+
// ca: options.ca,
28+
// key: options.key,
29+
// cert: options.cert,
30+
}
31+
});
32+
33+
34+
module.exports=pool;
35+
36+
37+
38+
39+
40+
41+
42+
43+
44+
45+
46+
47+
48+
49+
50+
51+
52+
// const client = new Client({
53+
// host: 'my.database-server.com',
54+
// port: 5334,
55+
// database: 'database-name',
56+
// user: 'database-user',
57+
// password: 'secretpassword!!',
58+
// })

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/node_modules
2+
/.config/.env
3+
/.env
4+
/.env.example
5+
/.eslintrc.js

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Collaborative_Code_Editor-
2+
<h1>Backend server for a web-based collaborative code editor</h1>
3+
4+
<p>Express-validation using joi : <a href="https://www.npmjs.com/package/express-validation">link</a></p>

config.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// console.log(process.env.TEST)
2+
3+
module.exports = {
4+
5+
port: process.env.PORT,
6+
DATABASE_URL: process.env.DATABASE_URL,
7+
DB_HOST: process.env.DB_HOST,
8+
DB_USER: process.env.DB_USER,
9+
DB_PASSWORD: process.env.DB_PASSWORD,
10+
DB_PORT: process.env.DB_PORT,
11+
DB_NAME: process.env.DB_NAME,
12+
SSL_CA: process.env.SSL_CA,
13+
SSL_KEY: process.env.SSL_KEY,
14+
SSL_CERT: process.env.SSL_CERT,
15+
SECRET: process.env.SECRET,
16+
JWT_SECRET: process.env.JWT_SECRET,
17+
18+
};
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
-- migrate:up
2+
3+
-- create table schema_name.table_name(elements);
4+
CREATE TABLE editor_schema.user (
5+
id UUID NOT NULL DEFAULT gen_random_uuid() ,
6+
name STRING NOT NULL,
7+
email STRING NOT NULL,
8+
password STRING NOT NULL,
9+
createdAt TIMESTAMP DEFAULT NOW() ON UPDATE NOW(),
10+
CONSTRAINT "pk_user_id" PRIMARY KEY(id ASC)
11+
);
12+
13+
14+
-- migrate:down
15+
16+
DROP TABLE IF EXISTS editor_schema.user;
17+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
-- migrate:up
2+
ALTER TABLE IF EXISTS editor_schema.user ADD COLUMN token STRING;
3+
4+
-- migrate:down
5+
6+
ALTER TABLE IF EXISTS editor_schema.user DROP COLUMN token;

db/migrations/20230927071254_code.sql

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
-- migrate:up
2+
CREATE TABLE editor_schema.code (
3+
cid UUID NOT NULL DEFAULT gen_random_uuid() ,
4+
code STRING NOT NULL,
5+
createdAt TIMESTAMP DEFAULT NOW() ON UPDATE NOW(),
6+
CONSTRAINT "pk_code_cid" PRIMARY KEY(cid ASC)
7+
);
8+
9+
10+
-- migrate:down
11+
DROP TABLE IF EXISTS editor_schema.code;
12+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
-- migrate:up
2+
ALTER TABLE IF EXISTS editor_schema.code ADD COLUMN users STRING;
3+
4+
-- migrate:down
5+
6+
ALTER TABLE IF EXISTS editor_schema.code DROP COLUMN users;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
-- migrate:up
2+
ALTER TABLE IF EXISTS editor_schema.user ADD COLUMN code_id STRING;
3+
4+
-- migrate:down
5+
6+
ALTER TABLE IF EXISTS editor_schema.user DROP COLUMN code_id;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
-- migrate:up
2+
create table editor_schema.versionHistory (
3+
vid UUID NOT NULL DEFAULT gen_random_uuid(),
4+
cid UUID REFERENCES editor_schema.code(cid) ON DELETE CASCADE,
5+
content STRING NOT NULL,
6+
createdAt TIMESTAMP DEFAULT NOW() ,
7+
userId UUID REFERENCES editor_schema.user(id)
8+
);
9+
10+
-- migrate:down
11+
DROP TABLE IF EXISTS editor_schema.versionHistory;

0 commit comments

Comments
 (0)