Skip to content
This repository was archived by the owner on Sep 15, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
17 changes: 17 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module.exports = {
"env": {
"browser": true,
"commonjs": true,
"es6": true
},
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
},
"parserOptions": {
"ecmaVersion": 2018
},
"rules": {
"semi": ["error", "never"]
}
};
10 changes: 5 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const app = express()
app.use(express.static(path.join(__dirname, 'public')))

app.get('/', function(req, res) {
res.send('Get ready for OpenSea!');
res.send('Get ready for OpenSea!')
})

app.get('/api/token/:token_id', function(req, res) {
Expand All @@ -38,14 +38,14 @@ app.get('/api/token/:token_id', function(req, res) {
})

app.listen(app.get('port'), function() {
console.log('Node app is running on port', app.get('port'));
console.log('Node app is running on port', app.get('port'))
})

// returns the zodiac sign according to day and month ( https://coursesweb.net/javascript/zodiac-signs_cs )
function zodiac(day, month) {
var zodiac =['', 'Capricorn', 'Aquarius', 'Pisces', 'Aries', 'Taurus', 'Gemini', 'Cancer', 'Leo', 'Virgo', 'Libra', 'Scorpio', 'Sagittarius', 'Capricorn'];
var last_day =['', 19, 18, 20, 20, 21, 21, 22, 22, 21, 22, 21, 20, 19];
return (day > last_day[month]) ? zodiac[month*1 + 1] : zodiac[month];
var zodiac =['', 'Capricorn', 'Aquarius', 'Pisces', 'Aries', 'Taurus', 'Gemini', 'Cancer', 'Leo', 'Virgo', 'Libra', 'Scorpio', 'Sagittarius', 'Capricorn']
var last_day =['', 19, 18, 20, 20, 21, 21, 22, 22, 21, 22, 21, 20, 19]
return (day > last_day[month]) ? zodiac[month*1 + 1] : zodiac[month]
}

function monthName(month) {
Expand Down
28 changes: 14 additions & 14 deletions test.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
const { spawn } = require('child_process');
const request = require('request');
const test = require('tape');
const { spawn } = require('child_process')
const request = require('request')
const test = require('tape')

// Start the app
const env = Object.assign({}, process.env, {PORT: 5000});
const child = spawn('node', ['index.js'], {env});
const env = Object.assign({}, process.env, {PORT: 5000})
const child = spawn('node', ['index.js'], {env})

test('responds to requests', (t) => {
t.plan(4);
t.plan(4)

// Wait until the server is ready
child.stdout.on('data', _ => {
// Make a request to our app
request('http://127.0.0.1:5000', (error, response, body) => {
// stop the server
child.kill();
child.kill()

// No error
t.false(error);
t.false(error)
// Successful response
t.equal(response.statusCode, 200);
t.equal(response.statusCode, 200)
// Assert content checks
t.notEqual(body.indexOf("Get ready"), -1);
t.notEqual(body.indexOf("for OpenSea!"), -1);
});
});
});
t.notEqual(body.indexOf("Get ready"), -1)
t.notEqual(body.indexOf("for OpenSea!"), -1)
})
})
})