[Snippets] Improve ts
This commit is contained in:
@@ -1,43 +1,28 @@
|
|||||||
{
|
{
|
||||||
"JS-Class": {
|
|
||||||
"prefix": "jsSetupClass",
|
|
||||||
"body": "class $1 { \n\tconstructor () {} \n\n \t$2 () {\n\t$3\n\t}\n}",
|
|
||||||
"description": "Setup the basic structure of a class in JS"
|
|
||||||
},
|
|
||||||
"ExpressJS": {
|
"ExpressJS": {
|
||||||
"prefix": "jsExpressSetup",
|
"prefix": "setupExpressApp",
|
||||||
"body": [
|
"body": [
|
||||||
"const express = require( 'express' );",
|
"import express from 'express';",
|
||||||
"let app = express();",
|
"import path from 'path';",
|
||||||
"const path = require( 'path' );",
|
"import expressSession from 'express-session';",
|
||||||
"const expressSession = require( 'express-session' );",
|
"import fs from 'fs';\n",
|
||||||
"const fs = require( 'fs' );",
|
"let app = express();",
|
||||||
"const bodyParser = require( 'body-parser' );",
|
"\napp.use( expressSession ( {\n\tsecret: $1,\n\tresave: true,\n\tsaveUninitialized: false\n} ) );",
|
||||||
"const cookieParser = require( 'cookie-parser' )",
|
|
||||||
"const favicon = require( 'serve-favicon' );",
|
|
||||||
"\napp.use( expressSession ( {\n\tsecret: $1,\n\tresave: true,\n\tsaveUninitialized: true\n} ) );",
|
|
||||||
"app.use( bodyParser.urlencoded( { extended: false } ) );",
|
|
||||||
"app.use( bodyParser.json() );",
|
|
||||||
"app.use( cookieParser() );",
|
|
||||||
"app.use( favicon( path.join( __dirname + '$2' ) ) );\n",
|
|
||||||
"app.use( ( request, response, next ) => {\n\tresponse.sendFile( path.join( __dirname + '$3' ) ) \n} );",
|
|
||||||
"\n\napp.get( '/', ( request, response ) => {\n$4\n} );",
|
"\n\napp.get( '/', ( request, response ) => {\n$4\n} );",
|
||||||
|
"app.use( ( _request: express.Request, response: express.Response ) => {",
|
||||||
|
"\tresponse.sendFile( path.join( __dirname, '$3' ) ) \n} );",
|
||||||
"\n\nconst PORT = process.env.PORT || 8080;",
|
"\n\nconst PORT = process.env.PORT || 8080;",
|
||||||
"http.createServer( app ).listen( PORT );"
|
"app.listen( PORT );"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"ExpressJS-Route": {
|
"ExpressJS-Route": {
|
||||||
"prefix": "jsEjsRoute",
|
"prefix": "expressRoute",
|
||||||
"body": "\n\napp.get( '$1', ( request: express.Request, response: express.Response ) => {\n$4\n} );"
|
"body": "\n\napp.get( '$1', ( request: express.Request, response: express.Response ) => {\n$4\n} );"
|
||||||
},
|
},
|
||||||
"JSAsync": {
|
"JSAsync": {
|
||||||
"prefix": "jsAsync",
|
"prefix": "async-sync",
|
||||||
"body": "(async () => {\n$1\n} ) ();"
|
"body": "(async () => {\n$1\n} ) ();"
|
||||||
},
|
},
|
||||||
"JSpromiseReturnFunc": {
|
|
||||||
"prefix": "jsPromise",
|
|
||||||
"body": "function $1 () {\n\treturn new Promise( ( resolve, reject ) => {\n\t$2\n\t} );\n}"
|
|
||||||
},
|
|
||||||
"fetch from other url": {
|
"fetch from other url": {
|
||||||
"prefix": "remoteURL",
|
"prefix": "remoteURL",
|
||||||
"body": [
|
"body": [
|
||||||
|
|||||||
@@ -9,13 +9,9 @@
|
|||||||
"description": "Setup the basic structure of a class in JS"
|
"description": "Setup the basic structure of a class in JS"
|
||||||
},
|
},
|
||||||
"JSAsync": {
|
"JSAsync": {
|
||||||
"prefix": "jsAsync",
|
"prefix": "async-sync",
|
||||||
"body": "(async () => {\n$1\n} ) ();"
|
"body": "(async () => {\n$1\n} ) ();"
|
||||||
},
|
},
|
||||||
"JSpromiseReturnFunc": {
|
|
||||||
"prefix": "jsPromise",
|
|
||||||
"body": "function $1 () {\n\treturn new Promise( ( resolve, reject ) => {\n\t$2\n\t} );\n}"
|
|
||||||
},
|
|
||||||
"fetch from other url": {
|
"fetch from other url": {
|
||||||
"prefix": "remoteURL",
|
"prefix": "remoteURL",
|
||||||
"body": [
|
"body": [
|
||||||
|
|||||||
Reference in New Issue
Block a user