Skip to content

Commit c784ba7

Browse files
committed
initial commit
0 parents  commit c784ba7

File tree

24 files changed

+6556
-0
lines changed

24 files changed

+6556
-0
lines changed

.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
npm-debug.log

.editorconfig

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
root = true
2+
3+
# Unix-style newlines with a newline ending every file
4+
[*]
5+
end_of_line = lf
6+
insert_final_newline = true
7+
8+
# Matches multiple files with brace expansion notation
9+
# Set default charset
10+
[*.{js,jsx,html,sass}]
11+
charset = utf-8
12+
indent_style = space
13+
indent_size = 2
14+
trim_trailing_whitespace = true
15+
16+
# don't use {} for single extension. This won't work: [*.{css}]
17+
[*.css]
18+
indent_style = space
19+
indent_size = 2

.eslintignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
docs/
2+
log/
3+
public/

.eslintrc

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"env": {
3+
"mocha": true,
4+
"node": true
5+
},
6+
"globals": {
7+
"connect": true
8+
},
9+
"plugins": [
10+
"node",
11+
"promise",
12+
"security"
13+
],
14+
"extends": [
15+
"airbnb-base",
16+
"eslint:recommended",
17+
"plugin:node/recommended",
18+
"plugin:promise/recommended",
19+
"plugin:security/recommended"
20+
],
21+
"rules": {
22+
"comma-dangle": ["error", {
23+
"arrays": "always-multiline",
24+
"objects": "always-multiline",
25+
"imports": "always-multiline",
26+
"exports": "always-multiline",
27+
"functions": "ignore"
28+
}],
29+
"max-len": 0
30+
}
31+
}

.gitignore

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
8+
# Runtime data
9+
pids
10+
*.pid
11+
*.seed
12+
*.pid.lock
13+
14+
# Directory for instrumented libs generated by jscoverage/JSCover
15+
lib-cov
16+
17+
# Coverage directory used by tools like istanbul
18+
coverage
19+
20+
# nyc test coverage
21+
.nyc_output
22+
23+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
24+
.grunt
25+
26+
# Bower dependency directory (https://bower.io/)
27+
bower_components
28+
29+
# node-waf configuration
30+
.lock-wscript
31+
32+
# Compiled binary addons (http://nodejs.org/api/addons.html)
33+
build/Release
34+
35+
# Dependency directories
36+
node_modules/
37+
jspm_packages/
38+
39+
# Typescript v1 declaration files
40+
typings/
41+
42+
# Optional npm cache directory
43+
.npm
44+
45+
# Optional eslint cache
46+
.eslintcache
47+
48+
# Optional REPL history
49+
.node_repl_history
50+
51+
# Output of 'npm pack'
52+
*.tgz
53+
54+
# Yarn Integrity file
55+
.yarn-integrity
56+
57+
# dotenv environment variables file
58+
.env
59+
60+
# IDE
61+
.idea

Dockerfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FROM node:8.9-alpine
2+
3+
WORKDIR /usr/app
4+
5+
COPY package.json package-lock.json ./
6+
RUN npm install --loglevel=error --progess=false
7+
8+
COPY . .

README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# NodeJS Work Sample (roster editor)
2+
3+
Welcome to the Digication work sample for NodeJS developers! This is our way to get some experience working with you and to get an idea about your level of NodeJS skills and knowledge about common npm packages. There is no official time-limit for this exercise, but you should finish it within a week. We encourage you to take the time you need in order to provide quality work that best reflects your skills.
4+
5+
## Context
6+
7+
A new course roster editor is needed! Imagine we are building an app for a university, where we need to provide a way for administrators to manage who should be teaching or taking a course. The frontend will be implemented at a later time. Today our goal is to create a basic version of the backend.
8+
9+
## Data Models
10+
11+
- The `Course` has `id` and `name` fields.
12+
- The `User` consists of `id`, `name` and `email`.
13+
14+
### Relationships
15+
16+
The model relationship in this example is kept as simple as possible, think of it this way:
17+
- Courses have many users assigned of which some can be flagged as faculty.
18+
- Users can be enrolled in many courses
19+
20+
## API methods
21+
22+
- Add the necessary functionality to add/remove users to/from courses. This should also allow mark/flag a user as faculty of the course.
23+
- Provide a way to get the users enrolled in a given course (and their faculty status).
24+
- You do not need to provide CRUD APIs for the Users and Courses models, but feel free to do so if you need them.
25+
26+
## Technical Requirements
27+
28+
You have to use NodeJS >10.0, expressjs 4.x and a relational database. This work sample already includes SQLite but feel free to use a different one. Regarding an ORM and SQL query builder we have selected `sequelize` but the final choice is up to you.
29+
30+
Since your backend app will be used by other developers, documentation of the API (check the scripts in `package.json` for an idea how you could do this) and unit tests will be much appreciated. Please make sure to apply common design patterns and best practices.
31+
32+
Please also point out which recommendations regarding security would you have, given that React will be used to build the frontend.
33+
34+
## Encouragement
35+
36+
Please don't go overboard with using external packages and don't try to introduce extra complexity in your code just for the sake of showcasing your skills. A simple and elegant solution for this should be your goal.
37+
38+
Digication team members have worked through this work sample to make sure we are not asking for too much of your time. This shouldn't take you longer than a couple of hours depending on your knowledge and the bells and whistles you want to add.
39+
40+
We are looking forward to hearing from you!

config/environments/development.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module.exports = {
2+
database: {
3+
dialect: 'sqlite',
4+
storage: ':memory:',
5+
logging: false,
6+
define: {
7+
underscored: true,
8+
underscoredAll: true,
9+
freezeTableName: true,
10+
timestamps: true,
11+
},
12+
sync: { force: true },
13+
},
14+
};

config/environments/test.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module.exports = {
2+
database: {
3+
dialect: 'sqlite',
4+
storage: ':memory:',
5+
logging: false,
6+
define: {
7+
underscored: true,
8+
underscoredAll: true,
9+
freezeTableName: true,
10+
timestamps: true,
11+
},
12+
sync: { force: true },
13+
},
14+
};

config/index.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
const env = process.env.NODE_ENV || 'development';
2+
// eslint-disable-next-line security/detect-non-literal-require
3+
let config = require(`./environments/${env}`); // eslint-disable-line import/no-dynamic-require
4+
5+
const defaultConfig = {};
6+
7+
config = { ...defaultConfig, ...config };
8+
9+
module.exports = config;

0 commit comments

Comments
 (0)