mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-20 16:42:56 +00:00
test: add tests for routes
This commit is contained in:
committed by
Rainer Killinger
parent
751693bebc
commit
d3955b3cdd
@@ -13,33 +13,15 @@
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// the list provides option to easily implement "isHttpMethod" guard
|
||||
const httpVerbs = ['get', 'post', 'put', 'delete', 'patch', 'options',
|
||||
'head', 'checkout', 'copy', 'lock', 'merge', 'mkactivity', 'mkcol',
|
||||
'move', 'm-search', 'notify', 'purge', 'report', 'search', 'subscribe',
|
||||
'trace', 'unlock','unsubscribe'] as const;
|
||||
/**
|
||||
* Strings that can be used as HTTP verbs (e.g. in requests)
|
||||
* Strings that can be used as HTTP verbs (e.g. in requests): 'get' | 'post' | 'put' | 'delete' etc.
|
||||
*/
|
||||
export type HTTPVerb = 'all' |
|
||||
'get' |
|
||||
'post' |
|
||||
'put' |
|
||||
'delete' |
|
||||
'patch' |
|
||||
'options' |
|
||||
'head' |
|
||||
'checkout' |
|
||||
'copy' |
|
||||
'lock' |
|
||||
'merge' |
|
||||
'mkactivity' |
|
||||
'mkcol' |
|
||||
'move' |
|
||||
'm-search' |
|
||||
'notify' |
|
||||
'purge' |
|
||||
'report' |
|
||||
'search' |
|
||||
'subscribe' |
|
||||
'trace' |
|
||||
'unlock' |
|
||||
'unsubscribe';
|
||||
export type HTTPVerb = typeof httpVerbs[number];
|
||||
|
||||
/**
|
||||
* Provides information if a text (representing a method) is an HTTP verb
|
||||
@@ -47,5 +29,5 @@ export type HTTPVerb = 'all' |
|
||||
* @param method A text (representing a method) to check
|
||||
*/
|
||||
export function isHttpMethod(method: string): method is HTTPVerb {
|
||||
return ['get', 'post', 'put'].indexOf(method) > -1;
|
||||
return (httpVerbs as unknown as string[]).indexOf(method) > -1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user