-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsearch.ts
More file actions
33 lines (28 loc) · 825 Bytes
/
search.ts
File metadata and controls
33 lines (28 loc) · 825 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { readFileSync } from 'fs'
export type Post = {
id: number
title: string
kind: 'report' | 'gallery' | 'video' | 'banner' | 'informative'
publishedAt: string
createdAt: string
category: string[]
targets: string[]
}
export type PostFilter = {
title?: string
kind?: 'report' | 'gallery' | 'video' | 'banner' | 'informative'
category?: string
target?: string
publishedAtStart?: Date
publishedAtEnd?: Date
createdAtStart?: Date
createdAtEnd?: Date
}
export async function search(filter: PostFilter): Promise<Post[]> {
const posts: Post[] = JSON.parse(readFileSync('./data/posts.json', 'utf-8'))
/********************************************
* CODIFIQUE AQUI!
* Você deve implementar essa função
********************************************/
return posts
}