Remove fontWeight parameter, favor markdown

This commit is contained in:
Steven 2019-01-22 15:13:45 -05:00
parent 5d2ecce371
commit ee64fa3a18
3 changed files with 3 additions and 8 deletions

View File

@ -4,10 +4,7 @@ import { parse } from 'url';
export function parseRequest(req: IncomingMessage) { export function parseRequest(req: IncomingMessage) {
console.log('HTTP ' + req.url); console.log('HTTP ' + req.url);
const { pathname = '/', query = {} } = parse(req.url || '', true); const { pathname = '/', query = {} } = parse(req.url || '', true);
const { fontWeight, fontSize, images, md } = query; const { fontSize, images, md } = query;
if (Array.isArray(fontWeight)) {
throw new Error('Expected a single fontWeight');
}
if (Array.isArray(fontSize)) { if (Array.isArray(fontSize)) {
throw new Error('Expected a single fontSize'); throw new Error('Expected a single fontSize');
} }
@ -27,7 +24,6 @@ export function parseRequest(req: IncomingMessage) {
type: extension === 'jpeg' ? extension : 'png', type: extension === 'jpeg' ? extension : 'png',
text: decodeURIComponent(text), text: decodeURIComponent(text),
md: md === '1' || md === 'true', md: md === '1' || md === 'true',
fontWeight: fontWeight as FontWeight || 'bold',
fontSize: fontSize || '75px', fontSize: fontSize || '75px',
images: Array.isArray(images) && images.length > 0 images: Array.isArray(images) && images.length > 0
? images ? images

View File

@ -59,6 +59,7 @@
<li><a href="/hello world.png">/hello world.png</a></li> <li><a href="/hello world.png">/hello world.png</a></li>
<li><a href="/hello world.jpeg">/hello world.jpeg</a></li> <li><a href="/hello world.jpeg">/hello world.jpeg</a></li>
<li><a href="/small world.png?fontSize=50px">/small world.png?fontSize=50px</a></li> <li><a href="/small world.png?fontSize=50px">/small world.png?fontSize=50px</a></li>
<li><a href="/**bold** world.png?md=1">/**bold** world.png?md=1</a></li>
<li><a href="/TypeScript on Now.png?images=https://assets.zeit.co/image/upload/front/assets/design/now-black.svg&images=https://cdn.jsdelivr.net/gh/remojansen/logo.ts@master/ts.svg">TypeScript on Now</a></li> <li><a href="/TypeScript on Now.png?images=https://assets.zeit.co/image/upload/front/assets/design/now-black.svg&images=https://cdn.jsdelivr.net/gh/remojansen/logo.ts@master/ts.svg">TypeScript on Now</a></li>
<li><a href="/ZEIT and Hyper.png?images=https://assets.zeit.co/image/upload/front/assets/design/zeit-black-triangle.svg&images=https://assets.zeit.co/image/upload/front/assets/design/hyper-color-logo.svg">ZEIT and Hyper</a></li> <li><a href="/ZEIT and Hyper.png?images=https://assets.zeit.co/image/upload/front/assets/design/zeit-black-triangle.svg&images=https://assets.zeit.co/image/upload/front/assets/design/hyper-color-logo.svg">ZEIT and Hyper</a></li>
</ul> </ul>

4
types.d.ts vendored
View File

@ -1,11 +1,9 @@
type FontWeight = 'normal' | 'bold';
type ScreenshotType = 'png' | 'jpeg'; type ScreenshotType = 'png' | 'jpeg';
interface ParsedRequest { interface ParsedRequest {
type: ScreenshotType; type: ScreenshotType;
text: string; text: string;
md: boolean, md: boolean;
fontWeight: FontWeight;
fontSize: string; fontSize: string;
images: string[]; images: string[];
} }