/ snippets / typescript / application.json
application.json
 1  {
 2    "setGlobalPrefix Config": {
 3      "prefix": ["ns_app_set_global_prefix", "app.setGlobalPrefix"],
 4      "scope": "typescript",
 5      "body": "app.setGlobalPrefix('${1:prefix}');",
 6      "description": "Sets a global prefix for all routes. Useful for versioning or namespacing APIs."
 7    },
 8    "getGlobalPrefix Config": {
 9      "prefix": ["ns_app_get_global_prefix", "app.getGlobalPrefix"],
10      "scope": "typescript",
11      "body": "app.getGlobalPrefix();",
12      "description": "Returns the current global prefix."
13    },
14    "getIoAdapter Config": {
15      "prefix": ["ns_app_get_io_adapter", "app.getIoAdapter"],
16      "scope": "typescript",
17      "body": "app.getIoAdapter();",
18      "description": "Returns the current WebSocket adapter instance."
19    },
20    "useGlobalPipes Config": {
21      "prefix": ["ns_app_use_global_pipes", "app.useGlobalPipes"],
22      "scope": "typescript",
23      "body": "app.useGlobalPipes(${1:pipes});",
24      "description": "Registers pipes at the application level (e.g., ValidationPipe)."
25    },
26    "useGlobalFilters Config": {
27      "prefix": ["ns_app_use_global_filters", "app.useGlobalFilters"],
28      "scope": "typescript",
29      "body": "app.useGlobalFilters(${1:filters});",
30      "description": "Registers exception filters at the application level."
31    },
32    "useGlobalInterceptors Config": {
33      "prefix": ["ns_app_use_global_interceptors", "app.useGlobalInterceptors"],
34      "scope": "typescript",
35      "body": "app.useGlobalInterceptors(${1:interceptors});",
36      "description": "Registers interceptors at the application level."
37    },
38    "useGlobalGuards Config": {
39      "prefix": ["ns_app_use_global_guards", "app.useGlobalGuards"],
40      "scope": "typescript",
41      "body": "app.useGlobalGuards(${1:guards});",
42      "description": "Registers guards at the application level."
43    },
44    "getGlobalRequestGuards Config": {
45      "prefix": ["ns_app_get_global_request_guards", "app.getGlobalRequestGuards"],
46      "scope": "typescript",
47      "body": "app.getGlobalRequestGuards();",
48      "description": "Returns global guards that are bound to the request scope."
49    },
50    "getHttpAdapter Config": {
51      "prefix": ["ns_app_get_http_adapter", "app.getHttpAdapter"],
52      "scope": "typescript",
53      "body": "app.getHttpAdapter();",
54      "description": "Returns the underlying HTTP adapter (Express/Fastify)."
55    },
56    "init Config": {
57      "prefix": ["ns_app_init", "app.init"],
58      "scope": "typescript",
59      "body": "app.init();",
60      "description": "Initializes the Nest application (without starting the HTTP server)."
61    },
62    "connectMicroservice Config": {
63      "prefix": ["ns_app_connect_microservice", "app.connectMicroservice"],
64      "scope": "typescript",
65      "body": "app.connectMicroservice<MicroserviceOptions>(${1:microserviceOptions});",
66      "description": "Connects a microservice to the application using the given options."
67    },
68    "getHttpServer Config": {
69      "prefix": ["ns_app_get_http_server", "app.getHttpServer"],
70      "scope": "typescript",
71      "body": "app.getHttpServer();",
72      "description": "Returns the underlying HTTP server instance."
73    },
74    "useBodyParser Config": {
75      "prefix": ["ns_app_use_body_parser", "app.useBodyParser"],
76      "scope": "typescript",
77      "body": "app.useBodyParser(${1:args});",
78      "description": "Configures body parser options for the underlying HTTP adapter."
79    },
80    "enableCors Config": {
81      "prefix": ["ns_app_enable_cors", "app.enableCors"],
82      "scope": "typescript",
83      "body": "app.enableCors(${1:options});",
84      "description": "Enables CORS with optional configuration."
85    },
86    "listen Config": {
87      "prefix": ["ns_app_listen", "app.listen"],
88      "scope": "typescript",
89      "body": "app.listen(${1:3000}, '${2:0.0.0.0}');",
90      "description": "Starts the HTTP server. Use 'await' inside an async bootstrap function. Defaults: 3000 on 0.0.0.0."
91    },
92    "useWebSocketAdapter Config": {
93      "prefix": ["ns_app_use_web_socket_adapter", "app.useWebSocketAdapter"],
94      "scope": "typescript",
95      "body": "app.useWebSocketAdapter(${1:adapter});",
96      "description": "Sets a custom WebSocket adapter (e.g., for Fastify or custom drivers)."
97    }
98  }