Showing
3 changed files
with
26 additions
and
6 deletions
1 | const express = require('express') | 1 | const express = require('express') |
2 | const schedule = require('node-schedule') | 2 | const schedule = require('node-schedule') |
3 | 3 | ||
4 | -const dataFunctions = require('./functions/dataFunctions') | 4 | +const data = require('./functions/dataFunctions') |
5 | - | 5 | +const find = require('./functions/findFunction') |
6 | const app = express(); | 6 | const app = express(); |
7 | 7 | ||
8 | 8 | ||
9 | 9 | ||
10 | // 0초 0분 0시 아무날 아무달 아무년 | 10 | // 0초 0분 0시 아무날 아무달 아무년 |
11 | -const saveData = schedule.scheduleJob('55 45 20 * * *', dataFunctions.save) | 11 | +const saveData = schedule.scheduleJob('55 45 20 * * *', data.save) |
12 | 12 | ||
13 | const server = app.listen(3000,()=>{ | 13 | const server = app.listen(3000,()=>{ |
14 | const host = server.address().address | 14 | const host = server.address().address |
... | @@ -19,6 +19,6 @@ const server = app.listen(3000,()=>{ | ... | @@ -19,6 +19,6 @@ const server = app.listen(3000,()=>{ |
19 | 19 | ||
20 | app.get('/', async (req, res)=>{ | 20 | app.get('/', async (req, res)=>{ |
21 | 21 | ||
22 | - data = await dataFunctions.read() | 22 | + console.log(find.byCompanyName('naver')[0], find.byTags('백엔드')[0], find.byTitle('백엔드')[0]) |
23 | - res.send(data) | 23 | + res.send('helloworld') |
24 | }) | 24 | }) |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
1 | const fs = require('fs') | 1 | const fs = require('fs') |
2 | const functions = require('./function') | 2 | const functions = require('./function') |
3 | 3 | ||
4 | -const read = async () =>{ | 4 | +const read = () =>{ |
5 | const data = [] | 5 | const data = [] |
6 | let title = "" | 6 | let title = "" |
7 | let tags = [] | 7 | let tags = [] | ... | ... |
functions/findFunction.js
0 → 100644
1 | +const data = require('./dataFunctions') | ||
2 | + | ||
3 | + | ||
4 | +const byCompanyName = function(companyName){ | ||
5 | + return data.read().filter(data => data.companyName.includes(companyName)) | ||
6 | +} | ||
7 | + | ||
8 | +const byTags = function(tag){ | ||
9 | + return data.read().filter(data => data.tags.join().includes(tag)) | ||
10 | +} | ||
11 | + | ||
12 | +const byTitle = function(title){ | ||
13 | + return data.read().filter(data => data.title.includes(title)) | ||
14 | +} | ||
15 | + | ||
16 | +module.exports = { | ||
17 | + byCompanyName : byCompanyName, | ||
18 | + byTags : byTags, | ||
19 | + byTitle : byTitle | ||
20 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
-
Please register or login to post a comment