Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"editor.formatOnSave": true
}
50 changes: 25 additions & 25 deletions api-server/categories.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
const clone = require('clone')
const config = require('./config')
const clone = require("clone");
const config = require("./config");

let db = {}
let db = {};

const defaultData = {
categories: [
{
name: 'react',
path: 'react'
},
{
name: 'redux',
path: 'redux'
},
{
name: 'udacity',
path: 'udacity'
}
{
name: "react",
path: "react"
},
{
name: "redux",
path: "redux"
},
{
name: "udacity",
path: "udacity"
}
]
}
};

function getData (token) {
function getData(token) {
//Each token has it's own copy of the DB. The token in this case is like an app id.
let data = db[token]
let data = db[token];
//This populates the default user data if there isn't any in the db.
if (data == null) {
data = db[token] = clone(defaultData)
data = db[token] = clone(defaultData);
}
return data
return data;
}

function getAll (token) {
return new Promise((res) => {
res(getData(token))
})
function getAll(token) {
return new Promise(res => {
res(getData(token));
});
}

module.exports = {
getAll
}
};
Loading