-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcomo.js
More file actions
68 lines (53 loc) · 1.55 KB
/
como.js
File metadata and controls
68 lines (53 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
const connect = require('camo').connect;
const Movie = require('./camoDoc');
const dataDoc = require('./dataDoc');
const express = require('express');
const CryptoJS = require('crypto-js');
const app = express();
require('dotenv').config();
const port = process.env.PORT || 3000;
var database;
// var uri = 'mongodb://localhost:27017/mongojk';
const uri = 'nedb://dbs/';
connect(uri).then(function(db) {
database = db;
});
app.listen(port, () => console.log(port));
app.get('/', async(req, res) => {
return res.send(await Movie.findAllRMovies());
});
app.get('/add', async(req, res) => {
var obj = {};
obj['name'] = 'kinjal';
obj['surname'] = 'bathani';
var thor = Movie.create({
title: 'Thor',
rating: 'PG-13',
dataObj: obj,
});
thor.save();
res.redirect('/');
});
app.get('/addData', async(req, res) => {
var thor = Movie.create({
title: 'Thor',
rating: 'PG-13',
releaseDate: new Date(2011, 4, 2),
hasCreditCookie: true
});
console.log(1);
var ciphertext = CryptoJS.AES.encrypt(JSON.stringify(thor), 'jk').toString();
console.log(1);
var data = dataDoc.create({
title: ciphertext
});
console.log(1);
data.save();
var bytes = CryptoJS.AES.decrypt(ciphertext, 'jk');
var decryptedData = JSON.parse(bytes.toString(CryptoJS.enc.Utf8));
// var encrypted = await CryptoJS.AES.encrypt(d, pass);
res.send({ ciphertext, decryptedData });
});
// .then(async function(t) {
// console.log(await Movie.findAllRMovies());
// });