Browse Source

Started project by creating simple user functionality methods and set up node dependencies.

pull/6/head
jrtechs 5 years ago
parent
commit
d75ee93184
2 changed files with 50 additions and 0 deletions
  1. +26
    -0
      fileIO.js
  2. +24
    -0
      server.js

+ 26
- 0
fileIO.js View File

@ -0,0 +1,26 @@
/** Used to read and write files from disk */
const fs = require('fs');
module.exports =
{
writeJSONToFile: function(fileName, jsonObject)
{
const json = JSON.stringify(jsonObject, null, 4);
fs.writeFile(fileName, json, 'utf8', function()
{
console.log("Wrote to " + fileName);
});
},
/**
*
* @param fileName
* @returns {any}
*/
getFileAsJSON: function(fileName)
{
return JSON.parse(fs.readFileSync(fileName, 'utf8'));
}
};

+ 24
- 0
server.js View File

@ -0,0 +1,24 @@
/** express app for routing */
const express = require("express");
/**session data for login and storing preferences*/
const session = require('express-session');
const fileIO = require('./fileIO');
const app = express();
app.use(express.urlencoded());
app.use(express.json()); // if needed
/**Initializes sessions for login */
app.use(session({ secret: "sessionSecret", cookie: { maxAge: 6000000 }}));
/** Template engine */
const whiskers = require('whiskers');
const CONFIG_FILE_NAME = "conf.json";
const config = fileIO.getFileAsJSON(CONFIG_FILE_NAME);

Loading…
Cancel
Save