diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..2897ede Binary files /dev/null and b/.DS_Store differ diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b512c09 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +node_modules \ No newline at end of file diff --git a/README.md b/README.md index 6ba9955..92e2890 100644 --- a/README.md +++ b/README.md @@ -1 +1 @@ -# CiferSprint \ No newline at end of file +HQ instagram clone \ No newline at end of file diff --git a/app.js b/app.js new file mode 100644 index 0000000..88bd889 --- /dev/null +++ b/app.js @@ -0,0 +1,53 @@ +var createError = require('http-errors'); +var express = require('express'); +var path = require('path'); +var cookieParser = require('cookie-parser'); +var logger = require('morgan'); +var expressSession = require('express-session'); + +var indexRouter = require('./routes/index'); +var usersRouter = require('./routes/users'); +const passport = require('passport'); + +var app = express(); + +// view engine setup +app.set('views', path.join(__dirname, 'views')); +app.set('view engine', 'ejs'); + +app.use(expressSession({ + resave: false, + saveUninitialized: false, + secret: "heyheyehhdd" +})); +app.use(passport.initialize()); +app.use(passport.session()); +passport.serializeUser(usersRouter.serializeUser()); +passport.deserializeUser(usersRouter.deserializeUser()); + +app.use(logger('dev')); +app.use(express.json()); +app.use(express.urlencoded({ extended: false })); +app.use(cookieParser()); +app.use(express.static(path.join(__dirname, 'public'))); + +app.use('/', indexRouter); +app.use('/users', usersRouter); + +// catch 404 and forward to error handler +app.use(function(req, res, next) { + next(createError(404)); +}); + +// error handler +app.use(function(err, req, res, next) { + // set locals, only providing error in development + res.locals.message = err.message; + res.locals.error = req.app.get('env') === 'development' ? err : {}; + + // render the error page + res.status(err.status || 500); + res.render('error'); +}); + +module.exports = app; diff --git a/bin/www b/bin/www new file mode 100644 index 0000000..fdf91a6 --- /dev/null +++ b/bin/www @@ -0,0 +1,90 @@ +#!/usr/bin/env node + +/** + * Module dependencies. + */ + +var app = require('../app'); +var debug = require('debug')('insta:server'); +var http = require('http'); + +/** + * Get port from environment and store in Express. + */ + +var port = normalizePort(process.env.PORT || '3000'); +app.set('port', port); + +/** + * Create HTTP server. + */ + +var server = http.createServer(app); + +/** + * Listen on provided port, on all network interfaces. + */ + +server.listen(port); +server.on('error', onError); +server.on('listening', onListening); + +/** + * Normalize a port into a number, string, or false. + */ + +function normalizePort(val) { + var port = parseInt(val, 10); + + if (isNaN(port)) { + // named pipe + return val; + } + + if (port >= 0) { + // port number + return port; + } + + return false; +} + +/** + * Event listener for HTTP server "error" event. + */ + +function onError(error) { + if (error.syscall !== 'listen') { + throw error; + } + + var bind = typeof port === 'string' + ? 'Pipe ' + port + : 'Port ' + port; + + // handle specific listen errors with friendly messages + switch (error.code) { + case 'EACCES': + console.error(bind + ' requires elevated privileges'); + process.exit(1); + break; + case 'EADDRINUSE': + console.error(bind + ' is already in use'); + process.exit(1); + break; + default: + throw error; + } +} + +/** + * Event listener for HTTP server "listening" event. + */ + +function onListening() { + var addr = server.address(); + var bind = typeof addr === 'string' + ? 'pipe ' + addr + : 'port ' + addr.port; + debug('Listening on ' + bind); +} diff --git a/db.json b/db.json new file mode 100644 index 0000000..97fa0d7 --- /dev/null +++ b/db.json @@ -0,0 +1,16 @@ +{ + "posts":[ + { + "username":"abhijit", + "password":"abhi@123" + }, + { + "username":"abhijit", + "password":"abhi@123" + }, + { + "username":"abhijit", + "password":"abhi@123" + } + ] +} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..7c348aa --- /dev/null +++ b/package-lock.json @@ -0,0 +1,1035 @@ +{ + "name": "insta", + "version": "0.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "insta", + "version": "0.0.0", + "dependencies": { + "cookie-parser": "~1.4.4", + "debug": "~2.6.9", + "ejs": "~2.6.1", + "express": "~4.16.1", + "express-session": "^1.17.3", + "http-errors": "~1.6.3", + "mongoose": "^8.1.1", + "morgan": "~1.9.1", + "multer": "^1.4.5-lts.1", + "passport": "^0.7.0", + "passport-local": "^1.0.0", + "passport-local-mongoose": "^8.0.0" + } + }, + "node_modules/@mongodb-js/saslprep": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/@mongodb-js/saslprep/-/saslprep-1.1.4.tgz", + "integrity": "sha512-8zJ8N1x51xo9hwPh6AWnKdLGEC5N3lDa6kms1YHmFBoRhTpJR6HG8wWk0td1MVCu9cD4YBrvjZEtd5Obw0Fbnw==", + "dependencies": { + "sparse-bitfield": "^3.0.3" + } + }, + "node_modules/@types/webidl-conversions": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/@types/webidl-conversions/-/webidl-conversions-7.0.3.tgz", + "integrity": "sha512-CiJJvcRtIgzadHCYXw7dqEnMNRjhGZlYK05Mj9OyktqV8uVT8fD2BFOB7S1uwBE3Kj2Z+4UyPmFw/Ixgw/LAlA==" + }, + "node_modules/@types/whatwg-url": { + "version": "11.0.4", + "resolved": "https://registry.npmjs.org/@types/whatwg-url/-/whatwg-url-11.0.4.tgz", + "integrity": "sha512-lXCmTWSHJvf0TRSO58nm978b8HJ/EdsSsEKLd3ODHFjo+3VGAyyTp4v50nWvwtzBxSMQrVOK7tcuN0zGPLICMw==", + "dependencies": { + "@types/webidl-conversions": "*" + } + }, + "node_modules/accepts": { + "version": "1.3.8", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz", + "integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==", + "dependencies": { + "mime-types": "~2.1.34", + "negotiator": "0.6.3" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/append-field": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/append-field/-/append-field-1.0.0.tgz", + "integrity": "sha512-klpgFSWLW1ZEs8svjfb7g4qWY0YS5imI82dTg+QahUvJ8YqAY0P10Uk8tTyh9ZGuYEZEMaeJYCF5BFuX552hsw==" + }, + "node_modules/array-flatten": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", + "integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==" + }, + "node_modules/basic-auth": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/basic-auth/-/basic-auth-2.0.1.tgz", + "integrity": "sha512-NF+epuEdnUYVlGuhaxbbq+dvJttwLnGY+YixlXlME5KpQ5W3CnXA5cVTneY3SPbPDRkcjMbifrwmFYcClgOZeg==", + "dependencies": { + "safe-buffer": "5.1.2" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/body-parser": { + "version": "1.18.3", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.18.3.tgz", + "integrity": "sha512-YQyoqQG3sO8iCmf8+hyVpgHHOv0/hCEFiS4zTGUwTA1HjAFX66wRcNQrVCeJq9pgESMRvUAOvSil5MJlmccuKQ==", + "dependencies": { + "bytes": "3.0.0", + "content-type": "~1.0.4", + "debug": "2.6.9", + "depd": "~1.1.2", + "http-errors": "~1.6.3", + "iconv-lite": "0.4.23", + "on-finished": "~2.3.0", + "qs": "6.5.2", + "raw-body": "2.3.3", + "type-is": "~1.6.16" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/bson": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/bson/-/bson-6.3.0.tgz", + "integrity": "sha512-balJfqwwTBddxfnidJZagCBPP/f48zj9Sdp3OJswREOgsJzHiQSaOIAtApSgDQFYgHqAvFkp53AFSqjMDZoTFw==", + "engines": { + "node": ">=16.20.1" + } + }, + "node_modules/buffer-from": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", + "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==" + }, + "node_modules/busboy": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/busboy/-/busboy-1.6.0.tgz", + "integrity": "sha512-8SFQbg/0hQ9xy3UNTB0YEnsNBbWfhf7RtnzpL7TkBiTBRfrQ9Fxcnz7VJsleJpyp6rVLvXiuORqjlHi5q+PYuA==", + "dependencies": { + "streamsearch": "^1.1.0" + }, + "engines": { + "node": ">=10.16.0" + } + }, + "node_modules/bytes": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz", + "integrity": "sha512-pMhOfFDPiv9t5jjIXkHosWmkSyQbvsgEVNkz0ERHbuLh2T/7j4Mqqpz523Fe8MVY89KC6Sh/QfS2sM+SjgFDcw==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/concat-stream": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", + "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", + "engines": [ + "node >= 0.8" + ], + "dependencies": { + "buffer-from": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^2.2.2", + "typedarray": "^0.0.6" + } + }, + "node_modules/content-disposition": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.2.tgz", + "integrity": "sha512-kRGRZw3bLlFISDBgwTSA1TMBFN6J6GWDeubmDE3AF+3+yXL8hTWv8r5rkLbqYXY4RjPk/EzHnClI3zQf1cFmHA==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/content-type": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz", + "integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.1.tgz", + "integrity": "sha512-ZwrFkGJxUR3EIoXtO+yVE69Eb7KlixbaeAWfBQB9vVsNn/o+Yw69gBWSSDK825hQNdN+wF8zELf3dFNl/kxkUA==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie-parser": { + "version": "1.4.6", + "resolved": "https://registry.npmjs.org/cookie-parser/-/cookie-parser-1.4.6.tgz", + "integrity": "sha512-z3IzaNjdwUC2olLIB5/ITd0/setiaFMLYiZJle7xg5Fe9KWAceil7xszYfHHBtDFYLSgJduS2Ty0P1uJdPDJeA==", + "dependencies": { + "cookie": "0.4.1", + "cookie-signature": "1.0.6" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/cookie-signature": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", + "integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ==" + }, + "node_modules/core-util-is": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", + "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==" + }, + "node_modules/debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dependencies": { + "ms": "2.0.0" + } + }, + "node_modules/depd": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", + "integrity": "sha512-7emPTl6Dpo6JRXOXjLRxck+FlLRX5847cLKEn00PLAgc3g2hTZZgr+e4c2v6QpSmLeFP3n5yUo7ft6avBK/5jQ==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/destroy": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", + "integrity": "sha512-3NdhDuEXnfun/z7x9GOElY49LoqVHoGScmOKwmxhsS8N5Y+Z8KyPPDnaSzqWgYt/ji4mqwfTS34Htrk0zPIXVg==" + }, + "node_modules/ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==" + }, + "node_modules/ejs": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/ejs/-/ejs-2.6.2.tgz", + "integrity": "sha512-PcW2a0tyTuPHz3tWyYqtK6r1fZ3gp+3Sop8Ph+ZYN81Ob5rwmbHEzaqs10N3BEsaGTkh/ooniXK+WwszGlc2+Q==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/encodeurl": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", + "integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==" + }, + "node_modules/etag": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", + "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/express": { + "version": "4.16.4", + "resolved": "https://registry.npmjs.org/express/-/express-4.16.4.tgz", + "integrity": "sha512-j12Uuyb4FMrd/qQAm6uCHAkPtO8FDTRJZBDd5D2KOL2eLaz1yUNdUB/NOIyq0iU4q4cFarsUCrnFDPBcnksuOg==", + "dependencies": { + "accepts": "~1.3.5", + "array-flatten": "1.1.1", + "body-parser": "1.18.3", + "content-disposition": "0.5.2", + "content-type": "~1.0.4", + "cookie": "0.3.1", + "cookie-signature": "1.0.6", + "debug": "2.6.9", + "depd": "~1.1.2", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "finalhandler": "1.1.1", + "fresh": "0.5.2", + "merge-descriptors": "1.0.1", + "methods": "~1.1.2", + "on-finished": "~2.3.0", + "parseurl": "~1.3.2", + "path-to-regexp": "0.1.7", + "proxy-addr": "~2.0.4", + "qs": "6.5.2", + "range-parser": "~1.2.0", + "safe-buffer": "5.1.2", + "send": "0.16.2", + "serve-static": "1.13.2", + "setprototypeof": "1.1.0", + "statuses": "~1.4.0", + "type-is": "~1.6.16", + "utils-merge": "1.0.1", + "vary": "~1.1.2" + }, + "engines": { + "node": ">= 0.10.0" + } + }, + "node_modules/express-session": { + "version": "1.17.3", + "resolved": "https://registry.npmjs.org/express-session/-/express-session-1.17.3.tgz", + "integrity": "sha512-4+otWXlShYlG1Ma+2Jnn+xgKUZTMJ5QD3YvfilX3AcocOAbIkVylSWEklzALe/+Pu4qV6TYBj5GwOBFfdKqLBw==", + "dependencies": { + "cookie": "0.4.2", + "cookie-signature": "1.0.6", + "debug": "2.6.9", + "depd": "~2.0.0", + "on-headers": "~1.0.2", + "parseurl": "~1.3.3", + "safe-buffer": "5.2.1", + "uid-safe": "~2.1.5" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/express-session/node_modules/cookie": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.2.tgz", + "integrity": "sha512-aSWTXFzaKWkvHO1Ny/s+ePFpvKsPnjc551iI41v3ny/ow6tBG5Vd+FuqGNhh1LxOmVzOlGUriIlOaokOvhaStA==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/express-session/node_modules/depd": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", + "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/express-session/node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/express/node_modules/cookie": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.3.1.tgz", + "integrity": "sha512-+IJOX0OqlHCszo2mBUq+SrEbCj6w7Kpffqx60zYbPTFaO4+yYgRjHwcZNpWvaTylDHaV7PPmBHzSecZiMhtPgw==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/finalhandler": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.1.tgz", + "integrity": "sha512-Y1GUDo39ez4aHAw7MysnUD5JzYX+WaIj8I57kO3aEPT1fFRL4sr7mjei97FgnwhAyyzRYmQZaTHb2+9uZ1dPtg==", + "dependencies": { + "debug": "2.6.9", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "on-finished": "~2.3.0", + "parseurl": "~1.3.2", + "statuses": "~1.4.0", + "unpipe": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/forwarded": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", + "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/fresh": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", + "integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/generaterr": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/generaterr/-/generaterr-1.5.0.tgz", + "integrity": "sha512-JgcGRv2yUKeboLvvNrq9Bm90P4iJBu7/vd5wSLYqMG5GJ6SxZT46LAAkMfNhQ+EK3jzC+cRBm7P8aUWYyphgcQ==" + }, + "node_modules/http-errors": { + "version": "1.6.3", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.3.tgz", + "integrity": "sha512-lks+lVC8dgGyh97jxvxeYTWQFvh4uw4yC12gVl63Cg30sjPX4wuGcdkICVXDAESr6OJGjqGA8Iz5mkeN6zlD7A==", + "dependencies": { + "depd": "~1.1.2", + "inherits": "2.0.3", + "setprototypeof": "1.1.0", + "statuses": ">= 1.4.0 < 2" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/iconv-lite": { + "version": "0.4.23", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.23.tgz", + "integrity": "sha512-neyTUVFtahjf0mB3dZT77u+8O0QB89jFdnBkd5P1JgYPbPaia3gXXOVL2fq8VyU2gMMD7SaN7QukTB/pmXYvDA==", + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha512-x00IRNXNy63jwGkJmzPigoySHbaqpNuzKbBOmzK+g2OdZpQ9w+sxCN+VSB3ja7IAge2OP2qpfxTjeNcyjmW1uw==" + }, + "node_modules/ipaddr.js": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", + "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==", + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==" + }, + "node_modules/kareem": { + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/kareem/-/kareem-2.5.1.tgz", + "integrity": "sha512-7jFxRVm+jD+rkq3kY0iZDJfsO2/t4BBPeEb2qKn2lR/9KhuksYk5hxzfRYWMPV8P/x2d0kHD306YyWLzjjH+uA==", + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/media-typer": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", + "integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/memory-pager": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/memory-pager/-/memory-pager-1.5.0.tgz", + "integrity": "sha512-ZS4Bp4r/Zoeq6+NLJpP+0Zzm0pR8whtGPf1XExKLJBAczGMnSi3It14OiNCStjQjM6NU1okjQGSxgEZN8eBYKg==" + }, + "node_modules/merge-descriptors": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", + "integrity": "sha512-cCi6g3/Zr1iqQi6ySbseM1Xvooa98N0w31jzUYrXPX2xqObmFGHJ0tQ5u74H3mVh7wLouTseZyYIq39g8cNp1w==" + }, + "node_modules/methods": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", + "integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.4.1.tgz", + "integrity": "sha512-KI1+qOZu5DcW6wayYHSzR/tXKCDC5Om4s1z2QJjDULzLcmf3DvzS7oluY4HCTrc+9FiKmWUgeNLg7W3uIQvxtQ==", + "bin": { + "mime": "cli.js" + } + }, + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/minimist": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", + "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/mkdirp": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", + "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", + "dependencies": { + "minimist": "^1.2.6" + }, + "bin": { + "mkdirp": "bin/cmd.js" + } + }, + "node_modules/mongodb": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-6.3.0.tgz", + "integrity": "sha512-tt0KuGjGtLUhLoU263+xvQmPHEGTw5LbcNC73EoFRYgSHwZt5tsoJC110hDyO1kjQzpgNrpdcSza9PknWN4LrA==", + "dependencies": { + "@mongodb-js/saslprep": "^1.1.0", + "bson": "^6.2.0", + "mongodb-connection-string-url": "^3.0.0" + }, + "engines": { + "node": ">=16.20.1" + }, + "peerDependencies": { + "@aws-sdk/credential-providers": "^3.188.0", + "@mongodb-js/zstd": "^1.1.0", + "gcp-metadata": "^5.2.0", + "kerberos": "^2.0.1", + "mongodb-client-encryption": ">=6.0.0 <7", + "snappy": "^7.2.2", + "socks": "^2.7.1" + }, + "peerDependenciesMeta": { + "@aws-sdk/credential-providers": { + "optional": true + }, + "@mongodb-js/zstd": { + "optional": true + }, + "gcp-metadata": { + "optional": true + }, + "kerberos": { + "optional": true + }, + "mongodb-client-encryption": { + "optional": true + }, + "snappy": { + "optional": true + }, + "socks": { + "optional": true + } + } + }, + "node_modules/mongodb-connection-string-url": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/mongodb-connection-string-url/-/mongodb-connection-string-url-3.0.0.tgz", + "integrity": "sha512-t1Vf+m1I5hC2M5RJx/7AtxgABy1cZmIPQRMXw+gEIPn/cZNF3Oiy+l0UIypUwVB5trcWHq3crg2g3uAR9aAwsQ==", + "dependencies": { + "@types/whatwg-url": "^11.0.2", + "whatwg-url": "^13.0.0" + } + }, + "node_modules/mongoose": { + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-8.1.1.tgz", + "integrity": "sha512-DbLb0NsiEXmaqLOpEz+AtAsgwhRw6f25gwa1dF5R7jj6lS1D8X6uTdhBSC8GDVtOwe5Tfw2EL7nTn6hiJT3Bgg==", + "dependencies": { + "bson": "^6.2.0", + "kareem": "2.5.1", + "mongodb": "6.3.0", + "mpath": "0.9.0", + "mquery": "5.0.0", + "ms": "2.1.3", + "sift": "16.0.1" + }, + "engines": { + "node": ">=16.20.1" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/mongoose" + } + }, + "node_modules/mongoose/node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" + }, + "node_modules/morgan": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/morgan/-/morgan-1.9.1.tgz", + "integrity": "sha512-HQStPIV4y3afTiCYVxirakhlCfGkI161c76kKFca7Fk1JusM//Qeo1ej2XaMniiNeaZklMVrh3vTtIzpzwbpmA==", + "dependencies": { + "basic-auth": "~2.0.0", + "debug": "2.6.9", + "depd": "~1.1.2", + "on-finished": "~2.3.0", + "on-headers": "~1.0.1" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/mpath": { + "version": "0.9.0", + "resolved": "https://registry.npmjs.org/mpath/-/mpath-0.9.0.tgz", + "integrity": "sha512-ikJRQTk8hw5DEoFVxHG1Gn9T/xcjtdnOKIU1JTmGjZZlg9LST2mBLmcX3/ICIbgJydT2GOc15RnNy5mHmzfSew==", + "engines": { + "node": ">=4.0.0" + } + }, + "node_modules/mquery": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/mquery/-/mquery-5.0.0.tgz", + "integrity": "sha512-iQMncpmEK8R8ncT8HJGsGc9Dsp8xcgYMVSbs5jgnm1lFHTZqMJTUWTDx1LBO8+mK3tPNZWFLBghQEIOULSTHZg==", + "dependencies": { + "debug": "4.x" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/mquery/node_modules/debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/mquery/node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + }, + "node_modules/ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" + }, + "node_modules/multer": { + "version": "1.4.5-lts.1", + "resolved": "https://registry.npmjs.org/multer/-/multer-1.4.5-lts.1.tgz", + "integrity": "sha512-ywPWvcDMeH+z9gQq5qYHCCy+ethsk4goepZ45GLD63fOu0YcNecQxi64nDs3qluZB+murG3/D4dJ7+dGctcCQQ==", + "dependencies": { + "append-field": "^1.0.0", + "busboy": "^1.0.0", + "concat-stream": "^1.5.2", + "mkdirp": "^0.5.4", + "object-assign": "^4.1.1", + "type-is": "^1.6.4", + "xtend": "^4.0.0" + }, + "engines": { + "node": ">= 6.0.0" + } + }, + "node_modules/negotiator": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", + "integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/on-finished": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", + "integrity": "sha512-ikqdkGAAyf/X/gPhXGvfgAytDZtDbr+bkNUJ0N9h5MI/dmdgCs3l6hoHrcUv41sRKew3jIwrp4qQDXiK99Utww==", + "dependencies": { + "ee-first": "1.1.1" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/on-headers": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/on-headers/-/on-headers-1.0.2.tgz", + "integrity": "sha512-pZAE+FJLoyITytdqK0U5s+FIpjN0JP3OzFi/u8Rx+EV5/W+JTWGXG8xFzevE7AjBfDqHv/8vL8qQsIhHnqRkrA==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/parseurl": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", + "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/passport": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/passport/-/passport-0.7.0.tgz", + "integrity": "sha512-cPLl+qZpSc+ireUvt+IzqbED1cHHkDoVYMo30jbJIdOOjQ1MQYZBPiNvmi8UM6lJuOpTPXJGZQk0DtC4y61MYQ==", + "dependencies": { + "passport-strategy": "1.x.x", + "pause": "0.0.1", + "utils-merge": "^1.0.1" + }, + "engines": { + "node": ">= 0.4.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/jaredhanson" + } + }, + "node_modules/passport-local": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/passport-local/-/passport-local-1.0.0.tgz", + "integrity": "sha512-9wCE6qKznvf9mQYYbgJ3sVOHmCWoUNMVFoZzNoznmISbhnNNPhN9xfY3sLmScHMetEJeoY7CXwfhCe7argfQow==", + "dependencies": { + "passport-strategy": "1.x.x" + }, + "engines": { + "node": ">= 0.4.0" + } + }, + "node_modules/passport-local-mongoose": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/passport-local-mongoose/-/passport-local-mongoose-8.0.0.tgz", + "integrity": "sha512-jgfN/B0j11WT5f96QlL5EBvxbIwmzd+tbwPzG1Vk8hzDOF68jrch5M+NFvrHjWjb3lfAU0DkxKmNRT9BjFZysQ==", + "dependencies": { + "generaterr": "^1.5.0", + "passport-local": "^1.0.0", + "scmp": "^2.1.0" + }, + "engines": { + "node": ">= 8.0.0" + } + }, + "node_modules/passport-strategy": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/passport-strategy/-/passport-strategy-1.0.0.tgz", + "integrity": "sha512-CB97UUvDKJde2V0KDWWB3lyf6PC3FaZP7YxZ2G8OAtn9p4HI9j9JLP9qjOGZFvyl8uwNT8qM+hGnz/n16NI7oA==", + "engines": { + "node": ">= 0.4.0" + } + }, + "node_modules/path-to-regexp": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", + "integrity": "sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ==" + }, + "node_modules/pause": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/pause/-/pause-0.0.1.tgz", + "integrity": "sha512-KG8UEiEVkR3wGEb4m5yZkVCzigAD+cVEJck2CzYZO37ZGJfctvVptVO192MwrtPhzONn6go8ylnOdMhKqi4nfg==" + }, + "node_modules/process-nextick-args": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", + "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==" + }, + "node_modules/proxy-addr": { + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", + "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==", + "dependencies": { + "forwarded": "0.2.0", + "ipaddr.js": "1.9.1" + }, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/punycode": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", + "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", + "engines": { + "node": ">=6" + } + }, + "node_modules/qs": { + "version": "6.5.2", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", + "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==", + "engines": { + "node": ">=0.6" + } + }, + "node_modules/random-bytes": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/random-bytes/-/random-bytes-1.0.0.tgz", + "integrity": "sha512-iv7LhNVO047HzYR3InF6pUcUsPQiHTM1Qal51DcGSuZFBil1aBBWG5eHPNek7bvILMaYJ/8RU1e8w1AMdHmLQQ==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/range-parser": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", + "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/raw-body": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.3.3.tgz", + "integrity": "sha512-9esiElv1BrZoI3rCDuOuKCBRbuApGGaDPQfjSflGxdy4oyzqghxu6klEkkVIvBje+FF0BX9coEv8KqW6X/7njw==", + "dependencies": { + "bytes": "3.0.0", + "http-errors": "1.6.3", + "iconv-lite": "0.4.23", + "unpipe": "1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/readable-stream": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.8.tgz", + "integrity": "sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==", + "dependencies": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "node_modules/safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + }, + "node_modules/safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" + }, + "node_modules/scmp": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/scmp/-/scmp-2.1.0.tgz", + "integrity": "sha512-o/mRQGk9Rcer/jEEw/yw4mwo3EU/NvYvp577/Btqrym9Qy5/MdWGBqipbALgd2lrdWTJ5/gqDusxfnQBxOxT2Q==" + }, + "node_modules/send": { + "version": "0.16.2", + "resolved": "https://registry.npmjs.org/send/-/send-0.16.2.tgz", + "integrity": "sha512-E64YFPUssFHEFBvpbbjr44NCLtI1AohxQ8ZSiJjQLskAdKuriYEP6VyGEsRDH8ScozGpkaX1BGvhanqCwkcEZw==", + "dependencies": { + "debug": "2.6.9", + "depd": "~1.1.2", + "destroy": "~1.0.4", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "fresh": "0.5.2", + "http-errors": "~1.6.2", + "mime": "1.4.1", + "ms": "2.0.0", + "on-finished": "~2.3.0", + "range-parser": "~1.2.0", + "statuses": "~1.4.0" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/serve-static": { + "version": "1.13.2", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.13.2.tgz", + "integrity": "sha512-p/tdJrO4U387R9oMjb1oj7qSMaMfmOyd4j9hOFoxZe2baQszgHcSWjuya/CiT5kgZZKRudHNOA0pYXOl8rQ5nw==", + "dependencies": { + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "parseurl": "~1.3.2", + "send": "0.16.2" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/setprototypeof": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.0.tgz", + "integrity": "sha512-BvE/TwpZX4FXExxOxZyRGQQv651MSwmWKZGqvmPcRIjDqWub67kTKuIMx43cZZrS/cBBzwBcNDWoFxt2XEFIpQ==" + }, + "node_modules/sift": { + "version": "16.0.1", + "resolved": "https://registry.npmjs.org/sift/-/sift-16.0.1.tgz", + "integrity": "sha512-Wv6BjQ5zbhW7VFefWusVP33T/EM0vYikCaQ2qR8yULbsilAT8/wQaXvuQ3ptGLpoKx+lihJE3y2UTgKDyyNHZQ==" + }, + "node_modules/sparse-bitfield": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/sparse-bitfield/-/sparse-bitfield-3.0.3.tgz", + "integrity": "sha512-kvzhi7vqKTfkh0PZU+2D2PIllw2ymqJKujUcyPMd9Y75Nv4nPbGJZXNhxsgdQab2BmlDct1YnfQCguEvHr7VsQ==", + "dependencies": { + "memory-pager": "^1.0.2" + } + }, + "node_modules/statuses": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.4.0.tgz", + "integrity": "sha512-zhSCtt8v2NDrRlPQpCNtw/heZLtfUDqxBM1udqikb/Hbk52LK4nQSwr10u77iopCW5LsyHpuXS0GnEc48mLeew==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/streamsearch": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/streamsearch/-/streamsearch-1.1.0.tgz", + "integrity": "sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg==", + "engines": { + "node": ">=10.0.0" + } + }, + "node_modules/string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "dependencies": { + "safe-buffer": "~5.1.0" + } + }, + "node_modules/tr46": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-4.1.1.tgz", + "integrity": "sha512-2lv/66T7e5yNyhAAC4NaKe5nVavzuGJQVVtRYLyQ2OI8tsJ61PMLlelehb0wi2Hx6+hT/OJUWZcw8MjlSRnxvw==", + "dependencies": { + "punycode": "^2.3.0" + }, + "engines": { + "node": ">=14" + } + }, + "node_modules/type-is": { + "version": "1.6.18", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", + "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==", + "dependencies": { + "media-typer": "0.3.0", + "mime-types": "~2.1.24" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/typedarray": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", + "integrity": "sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==" + }, + "node_modules/uid-safe": { + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/uid-safe/-/uid-safe-2.1.5.tgz", + "integrity": "sha512-KPHm4VL5dDXKz01UuEd88Df+KzynaohSL9fBh096KWAxSKZQDI2uBrVqtvRM4rwrIrRRKsdLNML/lnaaVSRioA==", + "dependencies": { + "random-bytes": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/unpipe": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", + "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==" + }, + "node_modules/utils-merge": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", + "integrity": "sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==", + "engines": { + "node": ">= 0.4.0" + } + }, + "node_modules/vary": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", + "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/webidl-conversions": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-7.0.0.tgz", + "integrity": "sha512-VwddBukDzu71offAQR975unBIGqfKZpM+8ZX6ySk8nYhVoo5CYaZyzt3YBvYtRtO+aoGlqxPg/B87NGVZ/fu6g==", + "engines": { + "node": ">=12" + } + }, + "node_modules/whatwg-url": { + "version": "13.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-13.0.0.tgz", + "integrity": "sha512-9WWbymnqj57+XEuqADHrCJ2eSXzn8WXIW/YSGaZtb2WKAInQ6CHfaUUcTyyver0p8BDg5StLQq8h1vtZuwmOig==", + "dependencies": { + "tr46": "^4.1.1", + "webidl-conversions": "^7.0.0" + }, + "engines": { + "node": ">=16" + } + }, + "node_modules/xtend": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", + "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==", + "engines": { + "node": ">=0.4" + } + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..0cd6815 --- /dev/null +++ b/package.json @@ -0,0 +1,22 @@ +{ + "name": "insta", + "version": "0.0.0", + "private": true, + "scripts": { + "start": "node ./bin/www" + }, + "dependencies": { + "cookie-parser": "~1.4.4", + "debug": "~2.6.9", + "ejs": "~2.6.1", + "express": "~4.16.1", + "express-session": "^1.17.3", + "http-errors": "~1.6.3", + "mongoose": "^8.1.1", + "morgan": "~1.9.1", + "multer": "^1.4.5-lts.1", + "passport": "^0.7.0", + "passport-local": "^1.0.0", + "passport-local-mongoose": "^8.0.0" + } +} diff --git a/public/.DS_Store b/public/.DS_Store new file mode 100644 index 0000000..65dd78a Binary files /dev/null and b/public/.DS_Store differ diff --git a/public/images/.DS_Store b/public/images/.DS_Store new file mode 100644 index 0000000..97a6208 Binary files /dev/null and b/public/images/.DS_Store differ diff --git a/public/images/image.png b/public/images/image.png new file mode 100644 index 0000000..0995e35 Binary files /dev/null and b/public/images/image.png differ diff --git a/public/images/logo.png b/public/images/logo.png new file mode 100644 index 0000000..9ad59dd Binary files /dev/null and b/public/images/logo.png differ diff --git a/public/images/sggs connect.png b/public/images/sggs connect.png new file mode 100644 index 0000000..1bb83ad Binary files /dev/null and b/public/images/sggs connect.png differ diff --git a/public/images/uploads/.DS_Store b/public/images/uploads/.DS_Store new file mode 100644 index 0000000..5008ddf Binary files /dev/null and b/public/images/uploads/.DS_Store differ diff --git a/public/images/uploads/.jpg b/public/images/uploads/.jpg new file mode 100644 index 0000000..69c3d37 Binary files /dev/null and b/public/images/uploads/.jpg differ diff --git a/public/images/uploads/.png b/public/images/uploads/.png new file mode 100644 index 0000000..69c3d37 Binary files /dev/null and b/public/images/uploads/.png differ diff --git a/public/images/uploads/00c14bf5-364b-414e-9adf-4b87d05034ea.png b/public/images/uploads/00c14bf5-364b-414e-9adf-4b87d05034ea.png new file mode 100644 index 0000000..6551802 Binary files /dev/null and b/public/images/uploads/00c14bf5-364b-414e-9adf-4b87d05034ea.png differ diff --git a/public/images/uploads/05d6018c563252041ef2360cb9395d3a.png b/public/images/uploads/05d6018c563252041ef2360cb9395d3a.png new file mode 100644 index 0000000..81e0cb7 Binary files /dev/null and b/public/images/uploads/05d6018c563252041ef2360cb9395d3a.png differ diff --git a/public/images/uploads/0c62bc234c0c6db102070a2e4235ab2d.jpg b/public/images/uploads/0c62bc234c0c6db102070a2e4235ab2d.jpg new file mode 100644 index 0000000..35cb4e9 Binary files /dev/null and b/public/images/uploads/0c62bc234c0c6db102070a2e4235ab2d.jpg differ diff --git a/public/images/uploads/27220a7f8a126997c3eeb27d0e865205.png b/public/images/uploads/27220a7f8a126997c3eeb27d0e865205.png new file mode 100644 index 0000000..3055bed Binary files /dev/null and b/public/images/uploads/27220a7f8a126997c3eeb27d0e865205.png differ diff --git a/public/images/uploads/32b8fcc53b73d5803b063e4686f4611c.jpg b/public/images/uploads/32b8fcc53b73d5803b063e4686f4611c.jpg new file mode 100644 index 0000000..50da3e9 Binary files /dev/null and b/public/images/uploads/32b8fcc53b73d5803b063e4686f4611c.jpg differ diff --git a/public/images/uploads/37f14e1976782022e9ce01a7688635f1.png b/public/images/uploads/37f14e1976782022e9ce01a7688635f1.png new file mode 100644 index 0000000..adb844b Binary files /dev/null and b/public/images/uploads/37f14e1976782022e9ce01a7688635f1.png differ diff --git a/public/images/uploads/4f3bb253a7eea7b63c147b46034c72d2.jpg b/public/images/uploads/4f3bb253a7eea7b63c147b46034c72d2.jpg new file mode 100644 index 0000000..970fab7 Binary files /dev/null and b/public/images/uploads/4f3bb253a7eea7b63c147b46034c72d2.jpg differ diff --git a/public/images/uploads/63794f6d98d3b7947d41c37a5e00ff20.jpg b/public/images/uploads/63794f6d98d3b7947d41c37a5e00ff20.jpg new file mode 100644 index 0000000..eee022f Binary files /dev/null and b/public/images/uploads/63794f6d98d3b7947d41c37a5e00ff20.jpg differ diff --git a/public/images/uploads/82c3cac1bb592a979fccedd78082ceca.jpg b/public/images/uploads/82c3cac1bb592a979fccedd78082ceca.jpg new file mode 100644 index 0000000..bb8db99 Binary files /dev/null and b/public/images/uploads/82c3cac1bb592a979fccedd78082ceca.jpg differ diff --git a/public/images/uploads/8cd79d93f89c4a95d1a88ad007180acf.jpg b/public/images/uploads/8cd79d93f89c4a95d1a88ad007180acf.jpg new file mode 100644 index 0000000..970fab7 Binary files /dev/null and b/public/images/uploads/8cd79d93f89c4a95d1a88ad007180acf.jpg differ diff --git a/public/images/uploads/91ae760c805ac215cfdb3db6fde8611b.png b/public/images/uploads/91ae760c805ac215cfdb3db6fde8611b.png new file mode 100644 index 0000000..bca3413 Binary files /dev/null and b/public/images/uploads/91ae760c805ac215cfdb3db6fde8611b.png differ diff --git a/public/images/uploads/9de25ced10c0acd2acf978675a3bb111.jpg b/public/images/uploads/9de25ced10c0acd2acf978675a3bb111.jpg new file mode 100644 index 0000000..4d63362 Binary files /dev/null and b/public/images/uploads/9de25ced10c0acd2acf978675a3bb111.jpg differ diff --git a/public/images/uploads/aeb2204c0254ca7f71ffe1abd4945ce2.jpg b/public/images/uploads/aeb2204c0254ca7f71ffe1abd4945ce2.jpg new file mode 100644 index 0000000..bb8db99 Binary files /dev/null and b/public/images/uploads/aeb2204c0254ca7f71ffe1abd4945ce2.jpg differ diff --git a/public/images/uploads/bf860b6bb8afc8717fa67be6347cc7ec.png b/public/images/uploads/bf860b6bb8afc8717fa67be6347cc7ec.png new file mode 100644 index 0000000..6d5ed88 Binary files /dev/null and b/public/images/uploads/bf860b6bb8afc8717fa67be6347cc7ec.png differ diff --git a/public/images/uploads/images.jpg b/public/images/uploads/images.jpg new file mode 100644 index 0000000..35cb4e9 Binary files /dev/null and b/public/images/uploads/images.jpg differ diff --git a/public/stylesheets/style.css b/public/stylesheets/style.css new file mode 100644 index 0000000..ca010b9 --- /dev/null +++ b/public/stylesheets/style.css @@ -0,0 +1,7 @@ +.story::-webkit-scrollbar{ + display: none; +} + +a:focus { + outline: none !important; +} \ No newline at end of file diff --git a/routes/index.js b/routes/index.js new file mode 100644 index 0000000..168d19b --- /dev/null +++ b/routes/index.js @@ -0,0 +1,312 @@ +var express = require("express"); +var router = express.Router(); +const passport = require("passport"); +const localStrategy = require("passport-local"); +const userModel = require("./users"); +const postModel = require("./posts"); +const storyModel = require("./story"); +passport.use(new localStrategy(userModel.authenticate())); +const upload = require("./multer"); +const utils = require("../utils/utils"); + + +// GET +router.get("/", function (req, res) { + res.render("index", { footer: false }); +}); + +router.get("/comment", function (req, res) { + res.render("comment", { footer: false }); +}); +router.get("/message", function (req, res) { + res.render("message", { footer: false }); +}); +router.get("/notification", function (req, res) { + res.render("notification", { footer: false }); +}); + +router.get("/login", function (req, res) { + res.render("login", { footer: false }); +}); + +router.get("/like/:postid", async function (req, res) { + const post = await postModel.findOne({ _id: req.params.postid }); + const user = await userModel.findOne({ username: req.session.passport.user }); + if (post.like.indexOf(user._id) === -1) { + post.like.push(user._id); + } else { + post.like.splice(post.like.indexOf(user._id), 1); + } + await post.save(); + res.json(post); +}); + +router.post("/comment/:postid", async function (req, res) { + try { + const post = await postModel.findOne({ _id: req.params.postid }); + const user = await userModel.findOne({ username: req.session.passport.user }); + + if (!post) { + return res.status(404).send("Post not found"); + } + + if (!user) { + return res.status(404).send("User not found"); + } + + const newComment = { + user: user._id, // Assuming comment schema has a field for user ID + text: req.body.comment + }; + + post.comments.push(newComment); + await post.save(); + + res.redirect("/feed"); + // res.status(200).send("Comment added successfully"); + } catch (error) { + console.error(error); + res.status(500).send("Internal Server Error"); + } +}); + +router.get("/feed", isLoggedIn, async function (req, res) { + let user = await userModel + .findOne({ username: req.session.passport.user }) + .populate("posts"); + + let stories = await storyModel.find({ user: { $ne: user._id } }) + .populate("user"); + + var uniq = {}; + var filtered = stories.filter(item => { + if(!uniq[item.user.id]){ + uniq[item.user.id] = " "; + return true; + } + else return false; + }) + + let posts = await postModel.find().populate("user"); + + res.render("feed", { + footer: true, + user, + posts, + stories: filtered, + dater: utils.formatRelativeTime, + }); +}); + +router.get("/profile", isLoggedIn, async function (req, res) { + let user = await userModel + .findOne({ username: req.session.passport.user }) + .populate("posts") + .populate("saved"); + console.log(user); + + res.render("profile", { footer: true, user }); +}); + +router.get("/profile/:user", isLoggedIn, async function (req, res) { + let user = await userModel.findOne({ username: req.session.passport.user }); + + if (user.username === req.params.user) { + res.redirect("/profile"); + } + + let userprofile = await userModel + .findOne({ username: req.params.user }) + .populate("posts"); + + res.render("userprofile", { footer: true, userprofile, user }); +}); + +router.get("/follow/:userid", isLoggedIn, async function (req, res) { + let followKarneWaala = await userModel.findOne({ + username: req.session.passport.user, + }); + + let followHoneWaala = await userModel.findOne({ _id: req.params.userid }); + + if (followKarneWaala.following.indexOf(followHoneWaala._id) !== -1) { + let index = followKarneWaala.following.indexOf(followHoneWaala._id); + followKarneWaala.following.splice(index, 1); + + let index2 = followHoneWaala.followers.indexOf(followKarneWaala._id); + followHoneWaala.followers.splice(index2, 1); + } else { + followHoneWaala.followers.push(followKarneWaala._id); + followKarneWaala.following.push(followHoneWaala._id); + } + + await followHoneWaala.save(); + await followKarneWaala.save(); + + res.redirect("back"); +}); + +router.get("/search", isLoggedIn, async function (req, res) { + let user = await userModel.findOne({ username: req.session.passport.user }); + res.render("search", { footer: true, user }); +}); + +router.get("/save/:postid", isLoggedIn, async function (req, res) { + let user = await userModel.findOne({ username: req.session.passport.user }); + + if (user.saved.indexOf(req.params.postid) === -1) { + user.saved.push(req.params.postid); + } else { + var index = user.saved.indexOf(req.params.postid); + user.saved.splice(index, 1); + } + await user.save(); + res.json(user); +}); + +router.get("/search/:user", isLoggedIn, async function (req, res) { + const searchTerm = `^${req.params.user}`; + const regex = new RegExp(searchTerm); + + let users = await userModel.find({ username: { $regex: regex } }); + + res.json(users); +}); + +router.get("/edit", isLoggedIn, async function (req, res) { + const user = await userModel.findOne({ username: req.session.passport.user }); + res.render("edit", { footer: true, user }); +}); + +router.get("/upload", isLoggedIn, async function (req, res) { + let user = await userModel.findOne({ username: req.session.passport.user }); + res.render("upload", { footer: true, user }); +}); + +router.post("/update", isLoggedIn, async function (req, res) { + const user = await userModel.findOneAndUpdate( + { username: req.session.passport.user }, + { username: req.body.username, name: req.body.name, bio: req.body.bio }, + { new: true } + ); + req.login(user, function (err) { + if (err) throw err; + res.redirect("/profile"); + }); +}); + +router.post( + "/post", + isLoggedIn, + upload.single("image"), + async function (req, res) { + const user = await userModel.findOne({ + username: req.session.passport.user, + }); + + if (req.body.category === "post") { + const post = await postModel.create({ + user: user._id, + caption: req.body.caption, + picture: req.file.filename, + }); + user.posts.push(post._id); + } + else if (req.body.category === "story") { + let story = await storyModel.create({ + story: req.file.filename, + user: user._id, + }); + user.stories.push(story._id); + } else { + res.send("tez mat chalo"); + } + + await user.save(); + res.redirect("/feed"); + } +); + +router.post( + "/upload", + isLoggedIn, + upload.single("image"), + async function (req, res) { + const user = await userModel.findOne({ + username: req.session.passport.user, + }); + user.picture = req.file.filename; + await user.save(); + res.redirect("/feed"); + } +); + +// POST + +//valid email check +router.post("/register", function (req, res) { + // Check if email ends with "@sggs.ac.in" + if (!req.body.email || !req.body.email.endsWith("@sggs.ac.in")) { + return res.status(400).send(` + + `); + } + + const user = new userModel({ + username: req.body.username, + email: req.body.email, + name: req.body.name, + link: req.body.link, + }); + + + + userModel.register(user, req.body.password).then(function (registereduser) { + passport.authenticate("local")(req, res, function () { + res.redirect("/"); +}); +}); + +}); + +//email valid + +router.post( + "/login", + function(req, res, next) { + passport.authenticate("local", function(err, user, info) { + if (err) { return next(err); } + if (!user) { return res.redirect("/login"); } + if (user.aporve) { // Assuming 'aporve' is a boolean variable + req.logIn(user, function(err) { + if (err) { return next(err); } + return res.redirect("/feed"); + }); + } else { + return res.redirect("/login"); + } + })(req, res, next); + } +); + +router.get("/logout", function (req, res) { + req.logout(function (err) { + if (err) { + return next(err); + } + res.redirect("/login"); + }); +}); + +function isLoggedIn(req, res, next) { + if (req.isAuthenticated()) { + return next(); + } else { + res.redirect("/login"); + } +} + +module.exports = router; diff --git a/routes/multer.js b/routes/multer.js new file mode 100644 index 0000000..c094699 --- /dev/null +++ b/routes/multer.js @@ -0,0 +1,17 @@ +const multer = require("multer"); +const path = require("path"); +const crypto = require("crypto"); + +const storage = multer.diskStorage({ + destination: function (req, file, cb) { + cb(null, "./public/images/uploads"); + }, + filename: function (req, file, cb) { + const fn = + crypto.randomBytes(16).toString("hex") + path.extname(file.originalname); + cb(null, fn); + }, +}); + +const upload = multer({ storage: storage }); +module.exports = upload; \ No newline at end of file diff --git a/routes/posts.js b/routes/posts.js new file mode 100644 index 0000000..98abf66 --- /dev/null +++ b/routes/posts.js @@ -0,0 +1,29 @@ +const mongoose = require('mongoose'); + +const postSchema = mongoose.Schema({ + user: { + type: mongoose.Schema.Types.ObjectId, + ref: "user" + }, + caption: String, + like: [{ + type: mongoose.Schema.Types.ObjectId, + ref: "user" + }], + comments: { + type: Array, + default: [] + }, + date: { + type: Date, + default: Date.now + }, + shares: [{ + type: mongoose.Schema.Types.ObjectId, + ref: "user" + }], + picture: String +}) + + +module.exports = mongoose.model("post", postSchema); \ No newline at end of file diff --git a/routes/story.js b/routes/story.js new file mode 100644 index 0000000..770c5ea --- /dev/null +++ b/routes/story.js @@ -0,0 +1,16 @@ +const mongoose = require('mongoose'); + +const storySchema = mongoose.Schema({ + user: { + type: mongoose.Schema.Types.ObjectId, + ref: "user" + }, + story: String, + date: { + type: Date, + default: Date.now + } +}) + + +module.exports = mongoose.model("story", storySchema); \ No newline at end of file diff --git a/routes/users.js b/routes/users.js new file mode 100644 index 0000000..757863e --- /dev/null +++ b/routes/users.js @@ -0,0 +1,55 @@ +const mongoose = require('mongoose'); +const plm = require("passport-local-mongoose"); + +mongoose.connect("mongodb://127.0.0.1:27017/instainsta"); + +const userSchema = mongoose.Schema({ + username: String, + name: String, + email: String, + password: String, + link:String, + anonymousid:String, + aporve:{ + type:Boolean, + default:false + }, + picture: { + type: String, + default: "def.png" + }, + contact: String, + bio: String, + stories: [ + { + type: mongoose.Schema.Types.ObjectId, + ref: "story" + } + ], + saved: [ + { + type: mongoose.Schema.Types.ObjectId, + ref: "post" + } + ], + posts: [{ + type: mongoose.Schema.Types.ObjectId, + ref: "post" + }], + followers: [ + { + type: mongoose.Schema.Types.ObjectId, + ref: "user" + } + ], + following: [ + { + type: mongoose.Schema.Types.ObjectId, + ref: "user" + } + ] +}) + +userSchema.plugin(plm); + +module.exports = mongoose.model("user", userSchema); \ No newline at end of file diff --git a/utils/utils.js b/utils/utils.js new file mode 100644 index 0000000..04477fb --- /dev/null +++ b/utils/utils.js @@ -0,0 +1,36 @@ +var utils = { + formatRelativeTime: function (date) { + const now = new Date(); + const diff = now - date; + + // Convert milliseconds to seconds + const seconds = Math.floor(diff / 1000); + + if (seconds < 60) { + return `${seconds}s`; + } + + const minutes = Math.floor(seconds / 60); + + if (minutes < 60) { + return `${minutes}m`; + } + + const hours = Math.floor(minutes / 60); + + if (hours < 24) { + return `${hours}h`; + } + + const days = Math.floor(hours / 24); + + if (days < 7) { + return `${days}d`; + } + + const weeks = Math.floor(days / 7); + + return `${weeks}w`; + } +} +module.exports = utils; \ No newline at end of file diff --git a/views/edit.ejs b/views/edit.ejs new file mode 100644 index 0000000..2221995 --- /dev/null +++ b/views/edit.ejs @@ -0,0 +1,41 @@ +<% include ./partials/header.ejs %> + + + +
+
+ profile +

Edit Profile

+ home +
+
+
+ +
+ +
+
+

Edit Account Details

+
+
+ + + + +
+
+
+ + +<% include ./partials/footer.ejs %> \ No newline at end of file diff --git a/views/error.ejs b/views/error.ejs new file mode 100644 index 0000000..7cf94ed --- /dev/null +++ b/views/error.ejs @@ -0,0 +1,3 @@ +

<%= message %>

+

<%= error.status %>

+
<%= error.stack %>
diff --git a/views/feed.ejs b/views/feed.ejs new file mode 100644 index 0000000..6401e2a --- /dev/null +++ b/views/feed.ejs @@ -0,0 +1,262 @@ +<% include ./partials/header.ejs %> +
+
+ +
+ + +
+
+
+ +
+ <% posts.reverse().forEach(function(post){ %> +
+
+
+ +
+

+ <%= post.user.username %> +

+
+ <%= dater(new Date(post.date)) %> +
+
+
+ +
+
+
+ <% if(post.like.indexOf(user._id)===-1){ %> + + <% } else { %> + + <% } %> + + +
+ +
+
+ <% if(user.saved.indexOf(post.id)===-1){ %> + + <% } else { %> + + <% } %> +
+

+ <%= post.like.length %> likes +

+

+ + <%= post.user.username %> + + <%= post.caption %> +

+ +
+ Comments + <% if (post.comments.length > 0) { %> + <% post.comments.forEach(comment => { %> +
+
<%= comment.user %>
+
<%= comment.text %>
+
+ <% }) %> + <% } else { %> +

No comments yet.

+ <% } %> + + +
+
+ + +
+ +
+
+
+ <% }) %> +
+
+ + + + + + <% include ./partials/footer.ejs %> \ No newline at end of file diff --git a/views/index.ejs b/views/index.ejs new file mode 100644 index 0000000..e7398bf --- /dev/null +++ b/views/index.ejs @@ -0,0 +1,97 @@ +<% include ./partials/header.ejs %> +
+
+ +
+ + + +
+ + +
+ + +
+ Already have an account ? Log In +
+
+ + + +<% include ./partials/footer.ejs %> \ No newline at end of file diff --git a/views/login.ejs b/views/login.ejs new file mode 100644 index 0000000..b284040 --- /dev/null +++ b/views/login.ejs @@ -0,0 +1,13 @@ +<% include ./partials/header.ejs %> +
+
+ +
+ + + +
+ Don't have an account ? Sign Up +
+
+<% include ./partials/footer.ejs %> \ No newline at end of file diff --git a/views/message.ejs b/views/message.ejs new file mode 100644 index 0000000..e69de29 diff --git a/views/notification.ejs b/views/notification.ejs new file mode 100644 index 0000000..be3eba6 --- /dev/null +++ b/views/notification.ejs @@ -0,0 +1,3 @@ +

+ New notification +

\ No newline at end of file diff --git a/views/partials/footer.ejs b/views/partials/footer.ejs new file mode 100644 index 0000000..b471d8a --- /dev/null +++ b/views/partials/footer.ejs @@ -0,0 +1,16 @@ +<% if(footer){ %> + +<% } %> + + + + \ No newline at end of file diff --git a/views/partials/header.ejs b/views/partials/header.ejs new file mode 100644 index 0000000..2ed087f --- /dev/null +++ b/views/partials/header.ejs @@ -0,0 +1,11 @@ + + + + + + Document + + + + + \ No newline at end of file diff --git a/views/profile.ejs b/views/profile.ejs new file mode 100644 index 0000000..3694c24 --- /dev/null +++ b/views/profile.ejs @@ -0,0 +1,50 @@ +<% include ./partials/header.ejs %> +
+ +
+
+ +
+
+
+

<%= user.posts.length %>

+

Posts

+
+
+

<%= user.followers.length %>

+

Followers

+
+
+

<%= user.following.length %>

+

Following

+
+
+
+
+

<%= user.name %>

+

<%= user.bio ?? "You have not set anything yet, (click edit profile to set)" %>

+
+
+ Edit Profile +
+
+ <% if(user.posts.length>0){ %> + <% user.posts.reverse().forEach(function(post){ %> +
+ +
+ <% }) %> + <% } else { %> +
+ no posts yet. +
+ <% } %> +
+
+<% include ./partials/footer.ejs %> \ No newline at end of file diff --git a/views/search.ejs b/views/search.ejs new file mode 100644 index 0000000..dd2bcfe --- /dev/null +++ b/views/search.ejs @@ -0,0 +1,44 @@ +<% include ./partials/header.ejs %> +
+
+ + +
+
+ +
+
+ + + <% include ./partials/footer.ejs %> \ No newline at end of file diff --git a/views/upload.ejs b/views/upload.ejs new file mode 100644 index 0000000..a82bef8 --- /dev/null +++ b/views/upload.ejs @@ -0,0 +1,58 @@ +<% include ./partials/header.ejs %> +
+
+ profile +

Upload Post

+ home +
+
+
+ + +
+ +
+
+
post
+
story
+
+
+ + + + + +
+
+ + +<% include ./partials/footer.ejs %> \ No newline at end of file diff --git a/views/userprofile.ejs b/views/userprofile.ejs new file mode 100644 index 0000000..8039483 --- /dev/null +++ b/views/userprofile.ejs @@ -0,0 +1,69 @@ +<% include ./partials/header.ejs %> +
+ + + + + + +
+
+ +
+
+
+

<%= userprofile.posts.length %>

+

Posts

+
+
+

<%= userprofile.followers.length %>

+

Followers

+
+
+

<%= userprofile.following.length %>

+

Following

+
+
+
+
+

<%= userprofile.name %>

+

<%= userprofile.bio ?? "You have not set anything yet, (click edit profile to set)" %>

+
+
+ <% if(user.following.indexOf(userprofile._id) === -1){ %> + Follow + <% } else { %> + Following + <% } %> + Message + Contact +
+
+ <% if(userprofile.posts.length>0){ %> + <% userprofile.posts.reverse().forEach(function(post){ %> +
+ +
+ <% }) %> + <% } else { %> +
+ no posts yet. +
+ <% } %> +
+
+<% include ./partials/footer.ejs %> \ No newline at end of file