Skip to content

Commit

Permalink
type: fix type errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Aug 24, 2020
1 parent bb411f6 commit 7bfc55e
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { ServerResponse } from 'http';
import types from './types.json';

const mime = Object.entries(types).reduce(
(all, [type, exts]) =>
Object.assign(all, ...exts.map(ext => ({ [ext]: type }))),
{}
const mime: Record<string, string> = Object.entries(types).reduce(
(all, [type, exts]) => Object.assign(all, [...exts].map(ext => ({ [ext]: type }))), {}
);

export const isRouteRequest = (uri: string = '') => {
Expand All @@ -18,6 +16,7 @@ export const sendMessage = (res: ServerResponse, channel: string, data: string)
};

export const sendFile = (res: ServerResponse, resource: string, status: number, file: string, ext: string) => {

res.writeHead(status, {
"Content-Type": mime[ext] || "application/octet-stream",
"Access-Control-Allow-Origin": "*"
Expand Down

0 comments on commit 7bfc55e

Please sign in to comment.