1
- import { METHODS } from "http" ;
2
1
import { URL } from "url" ;
3
2
import { readFile } from "fs/promises" ;
4
3
import path from "path" ;
5
4
import * as Router from "find-my-way-ts" ;
6
5
import { Model , Request } from "./metamodel" ;
7
6
7
+ const httpMethods = [ "HEAD" , "GET" , "POST" , "PUT" , "PATCH" , "DELETE" ] ;
8
8
export type JSONValue = string | number | boolean | JSONArray | JSONObject ;
9
9
interface JSONArray extends Array < JSONValue > { }
10
10
interface JSONObject {
@@ -62,7 +62,7 @@ export function splitSource(source: string): string[] {
62
62
let prev = 0 ;
63
63
while ( index < len ) {
64
64
// Beginning of a new command, we should find the method and proceede to the url.
65
- for ( const method of METHODS ) {
65
+ for ( const method of httpMethods ) {
66
66
if ( source . slice ( index , len ) . startsWith ( method ) ) {
67
67
index += method . length ;
68
68
break ;
@@ -80,7 +80,7 @@ export function splitSource(source: string): string[] {
80
80
if ( index == len ) return ;
81
81
let brackets = 0 ;
82
82
// If we found an http method, then we have found a new command.
83
- for ( const method of METHODS ) {
83
+ for ( const method of httpMethods ) {
84
84
if ( source . slice ( index , len ) . startsWith ( method ) ) {
85
85
return ;
86
86
}
@@ -131,7 +131,7 @@ function parseCommand(source: string, options: ParseOptions) {
131
131
const len = source . length ;
132
132
let index = 0 ;
133
133
// identify the method
134
- for ( const method of METHODS ) {
134
+ for ( const method of httpMethods ) {
135
135
if ( source . slice ( index , len ) . startsWith ( method ) ) {
136
136
data . method = method ;
137
137
index += method . length ;
0 commit comments