diff --git a/.eslintrc.json b/.eslintrc.json deleted file mode 100644 index 486a643..0000000 --- a/.eslintrc.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "root": true, - "parserOptions": { - "ecmaVersion": 12, - "sourceType": "module" - }, - "extends": ["eslint:recommended", "prettier"], - "env": { - "es2021": true, - "node": true - }, - "rules": { - "no-console": "error" - } -} diff --git a/.gitignore b/.gitignore index c6bba59..246d599 100644 --- a/.gitignore +++ b/.gitignore @@ -1,130 +1,2 @@ -# Logs -logs -*.log -npm-debug.log* -yarn-debug.log* -yarn-error.log* -lerna-debug.log* -.pnpm-debug.log* - -# Diagnostic reports (https://nodejs.org/api/report.html) -report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json - -# Runtime data -pids -*.pid -*.seed -*.pid.lock - -# Directory for instrumented libs generated by jscoverage/JSCover -lib-cov - -# Coverage directory used by tools like istanbul -coverage -*.lcov - -# nyc test coverage -.nyc_output - -# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) -.grunt - -# Bower dependency directory (https://bower.io/) -bower_components - -# node-waf configuration -.lock-wscript - -# Compiled binary addons (https://nodejs.org/api/addons.html) -build/Release - -# Dependency directories -node_modules/ -jspm_packages/ - -# Snowpack dependency directory (https://snowpack.dev/) -web_modules/ - -# TypeScript cache -*.tsbuildinfo - -# Optional npm cache directory -.npm - -# Optional eslint cache -.eslintcache - -# Optional stylelint cache -.stylelintcache - -# Microbundle cache -.rpt2_cache/ -.rts2_cache_cjs/ -.rts2_cache_es/ -.rts2_cache_umd/ - -# Optional REPL history -.node_repl_history - -# Output of 'npm pack' -*.tgz - -# Yarn Integrity file -.yarn-integrity - -# dotenv environment variable files -.env -.env.development.local -.env.test.local -.env.production.local -.env.local - -# parcel-bundler cache (https://parceljs.org/) -.cache -.parcel-cache - -# Next.js build output -.next -out - -# Nuxt.js build / generate output -.nuxt -dist - -# Gatsby files -.cache/ -# Comment in the public line in if your project uses Gatsby and not Next.js -# https://nextjs.org/blog/next-9-1#public-directory-support -# public - -# vuepress build output -.vuepress/dist - -# vuepress v2.x temp and cache directory -.temp -.cache - -# Docusaurus cache and generated files -.docusaurus - -# Serverless directories -.serverless/ - -# FuseBox cache -.fusebox/ - -# DynamoDB Local files -.dynamodb/ - -# TernJS port file -.tern-port - -# Stores VSCode versions used for testing VSCode extensions -.vscode-test - -# yarn v2 -.yarn/cache -.yarn/unplugged -.yarn/build-state.yml -.yarn/install-state.gz -.pnp.* +/dist +/node_modules \ No newline at end of file diff --git a/.prettierrc.json b/.prettierrc.json deleted file mode 100644 index e74ed9f..0000000 --- a/.prettierrc.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "trailingComma": "es5", - "tabWidth": 4, - "semi": false, - "singleQuote": true -} diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..cf631cf --- /dev/null +++ b/package-lock.json @@ -0,0 +1,54 @@ +{ + "name": "wisp-server-nmode", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "wisp-server-nmode", + "version": "1.0.0", + "license": "ISC", + "devDependencies": { + "@types/ws": "^8.5.10", + "typescript": "^5.3.3" + } + }, + "node_modules/@types/node": { + "version": "20.11.16", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.11.16.tgz", + "integrity": "sha512-gKb0enTmRCzXSSUJDq6/sPcqrfCv2mkkG6Jt/clpn5eiCbKTY+SgZUxo+p8ZKMof5dCp9vHQUAB7wOUTod22wQ==", + "dev": true, + "dependencies": { + "undici-types": "~5.26.4" + } + }, + "node_modules/@types/ws": { + "version": "8.5.10", + "resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.5.10.tgz", + "integrity": "sha512-vmQSUcfalpIq0R9q7uTo2lXs6eGIpt9wtnLdMv9LVpIjCA/+ufZRozlVoVelIYixx1ugCBKDhn89vnsEGOCx9A==", + "dev": true, + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/typescript": { + "version": "5.3.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.3.3.tgz", + "integrity": "sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw==", + "dev": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/undici-types": { + "version": "5.26.5", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", + "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", + "dev": true + } + } +} diff --git a/package.json b/package.json index 6f251b0..9bb4475 100644 --- a/package.json +++ b/package.json @@ -1,30 +1,23 @@ { - "about": { - "name": "wisp-server-node", - "description": "A wisp server implementation, written in NodeJS.", - "version": "1.0.0", - "author": "vys ", - "license": "AGPL-3.0-or-later" - }, - "repository": { - "type": "git", - "url": "https://github.com/MercuryWorkshop/wisp-server-node.git" - }, - "dependencies": { - "fs": "0.0.1-security", - "mime-types": "^2.1.35", - "path": "^0.12.7", - "ws": "^8.16.0" - }, - "devDependencies": { - "eslint": "^8.56.0", - "eslint-config-prettier": "^9.1.0", - "prettier": "^3.2.4" - }, - "scripts": { - "format:check": "prettier --check .", - "format:write": "prettier --write .", - "lint:check": "eslint .", - "lint:fix": "eslint --fix ." - } + "name": "wisp-server-nmode", + "version": "1.0.0", + "type": "commonjs", + "description": "", + "scripts": { + "build": "tsc", + "dev": "tsc --watch" + }, + "main": "dist/createServer.js", + "types": "dist/createServer.d.ts", + "files": [ + "dist", + "bin.js" + ], + "keywords": [], + "author": "", + "license": "ISC", + "devDependencies": { + "@types/ws": "^8.5.10", + "typescript": "^5.3.3" + } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml deleted file mode 100644 index 79905cd..0000000 --- a/pnpm-lock.yaml +++ /dev/null @@ -1,95 +0,0 @@ -lockfileVersion: '6.0' - -settings: - autoInstallPeers: true - excludeLinksFromLockfile: false - -dependencies: - fs: - specifier: 0.0.1-security - version: 0.0.1-security - mime-types: - specifier: ^2.1.35 - version: 2.1.35 - path: - specifier: ^0.12.7 - version: 0.12.7 - ws: - specifier: ^8.16.0 - version: 8.16.0 - -packages: - /fs@0.0.1-security: - resolution: - { - integrity: sha512-3XY9e1pP0CVEUCdj5BmfIZxRBTSDycnbqhIOGec9QYtmVH2fbLpj86CFWkrNOkt/Fvty4KZG5lTglL9j/gJ87w==, - } - dev: false - - /inherits@2.0.3: - resolution: - { - integrity: sha512-x00IRNXNy63jwGkJmzPigoySHbaqpNuzKbBOmzK+g2OdZpQ9w+sxCN+VSB3ja7IAge2OP2qpfxTjeNcyjmW1uw==, - } - dev: false - - /mime-db@1.52.0: - resolution: - { - integrity: sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==, - } - engines: { node: '>= 0.6' } - dev: false - - /mime-types@2.1.35: - resolution: - { - integrity: sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==, - } - engines: { node: '>= 0.6' } - dependencies: - mime-db: 1.52.0 - dev: false - - /path@0.12.7: - resolution: - { - integrity: sha512-aXXC6s+1w7otVF9UletFkFcDsJeO7lSZBPUQhtb5O0xJe8LtYhj/GxldoL09bBj9+ZmE2hNoHqQSFMN5fikh4Q==, - } - dependencies: - process: 0.11.10 - util: 0.10.4 - dev: false - - /process@0.11.10: - resolution: - { - integrity: sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A==, - } - engines: { node: '>= 0.6.0' } - dev: false - - /util@0.10.4: - resolution: - { - integrity: sha512-0Pm9hTQ3se5ll1XihRic3FDIku70C+iHUdT/W926rSgHV5QgXsYbKZN8MSC3tJtSkhuROzvsQjAaFENRXr+19A==, - } - dependencies: - inherits: 2.0.3 - dev: false - - /ws@8.16.0: - resolution: - { - integrity: sha512-HS0c//TP7Ina87TfiPUz1rQzMhHrl/SG2guqRcTOIUYD2q8uhUdNHZYJUaQ8aTGPzCh+c6oawMKW35nFl1dxyQ==, - } - engines: { node: '>=10.0.0' } - peerDependencies: - bufferutil: ^4.0.1 - utf-8-validate: '>=5.0.2' - peerDependenciesMeta: - bufferutil: - optional: true - utf-8-validate: - optional: true - dev: false diff --git a/src/createServer.ts b/src/createServer.ts new file mode 100644 index 0000000..ac614b4 --- /dev/null +++ b/src/createServer.ts @@ -0,0 +1,20 @@ +import WebSocket from "ws"; + +export function createWispServer() { + const wss = new WebSocket.Server({port: 8080 }); + + console.log("Wisp server node where the hell do I start"); + + wss.on("connection", (ws: WebSocket) => { + console.log("Client connected"); + + ws.on("message", (message: string) => { + console.log("Received message: " + message); + ws.send("Got " + message); + }); + + ws.on("close", () => { + console.log("Client disconnected"); + }); + }); +} diff --git a/src/index.js b/src/index.js deleted file mode 100644 index de871a1..0000000 --- a/src/index.js +++ /dev/null @@ -1 +0,0 @@ -// shit would go here if shit was done here diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..0227b4e --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,16 @@ +{ + "compilerOptions": { + "outDir": "dist", + "lib": ["ESNext"], + "target": "ESNext", + "module": "Node16", + "moduleResolution": "Node16", + "strict": true, + "stripInternal": true, + "esModuleInterop": true, + "declaration": true, + "sourceMap": true, + "resolveJsonModule": false + }, + "include": ["src"] +} \ No newline at end of file