{"id":18561728,"url":"https://github.com/devartsite/dftps","last_synced_at":"2025-04-10T03:31:07.303Z","repository":{"id":62422086,"uuid":"365526910","full_name":"DevArtSite/dftps","owner":"DevArtSite","description":"DFtpS is an FTP server on Deno","archived":false,"fork":false,"pushed_at":"2021-11-29T01:54:12.000Z","size":34124,"stargazers_count":4,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-10-17T18:46:35.066Z","etag":null,"topics":["deno","ftp-commands","ftp-server"],"latest_commit_sha":null,"homepage":"https://devartsite.github.io/dftps-guide/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DevArtSite.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-05-08T13:54:04.000Z","updated_at":"2022-07-23T07:55:16.000Z","dependencies_parsed_at":"2022-11-01T17:33:10.982Z","dependency_job_id":null,"html_url":"https://github.com/DevArtSite/dftps","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DevArtSite%2Fdftps","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DevArtSite%2Fdftps/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DevArtSite%2Fdftps/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DevArtSite%2Fdftps/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DevArtSite","download_url":"https://codeload.github.com/DevArtSite/dftps/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223424488,"owners_count":17142743,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["deno","ftp-commands","ftp-server"],"created_at":"2024-11-06T22:07:45.183Z","updated_at":"2024-11-06T22:07:45.721Z","avatar_url":"https://github.com/DevArtSite.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DFtpS - Deno Ftp Server\n\n![logo](./assets/dftps_logo.png)\n[![deno doc](https://doc.deno.land/badge.svg)](https://doc.deno.land/https/deno.land/x/dftps/mod.ts)\n  \nDFtpS is an FTP server based on [ftp-srv](https://github.com/autovance/ftp-srv) with Deno.\n\nCheck our guide in [https://devartsite.github.io/dftps-guide/guide/](https://devartsite.github.io/dftps-guide/)\n\n- [Install](#install)\n- [Make your own](#make-your-own)\n  - [Simple](#simple)\n  - [With database](#with-database)\n- [Log example](#log-example)\n- [Deno Dependencies](#deno-dependencies)\n- [List of FTP commands](#list-of-ftp-commands)\n- [Contributing](#contributing)\n- [References](#references)\n\n## Usage\n\n### Install\n\n```sh\ncurl -fsSL https://deno.land/x/dftps/install.sh | sh\n```\n\n### Install Specific Version\n\n```sh\ncurl -fsSL https://deno.land/x/dftps/install.sh | sh -s v1.0.0\n```\n\n* * *\n\n## Make your own\n\n### Simple\n\n- First, we import the Server class and type for user authentication.\n\n```ts\nimport { Server } from \"https://deno.land/x/dftps/server/mod.ts\";\nimport type { UsernameResolvable, LoginResolvable } from \"https://deno.land/x/dftps/server/connection.ts\";\n```\n\n- Then we just need to create an instance of Server with these options described below.\n  - [Listener Options](https://doc.deno.land/https/deno.land%2Fx%2Fdftps%2Fsrc%2Fserver%2Fmod.ts#FTPOptions)\n  - [FTPServer Options](https://doc.deno.land/https/deno.land%2Fx%2Fdftps%2Fsrc%2Fserver%2Fmod.ts#FTPServerOptions)\n\n```ts\nconst serve = new Server({ port: 21, hostname: \"127.0.0.1\" });\n```\n\n- All we have to do is wait for a new connection and check the veracity of it using the authentication tools (awaitUsername, awaitLogin).\n\n```ts\nfor await (const connection of serve) {\n  const { awaitUsername, awaitLogin } = connection;\n  /** waiting to receiving username from connection */\n  awaitUsername.then(({ username, resolveUsername }: UsernameResolvable) =\u003e {\n    if (!username !== \"my-username\") return resolveUsername.reject(\"Incorrect username!\");\n    resolveUsername.resolve();\n  });\n  /** waiting to receiving password from connection and finalize the user authenticate */\n  awaitLogin.then(({ password, resolvePassword }: LoginResolvable) =\u003e {\n    if (password !== \"my-password\") return resolvePassword.reject(\"Wrong password!\");\n    resolvePassword.resolve({ root: \"my-folder\", uid: 1000, gid: 1000 });\n  });\n}\n```\n\n### With database\n\n- To begin we will initially import the \"createDb\" function which will allow us to create a database and the \"Users\" model in addition to the imports mentioned above.\n\n  ```ts\n  import { verify, Model } from \"https://deno.land/x/dftps/deps.ts\";\n  import createDb from \"https://deno.land/x/dftps/src/db/mod.ts\";\n  import Users from \"https://deno.land/x/dftps/src/db/Users.ts\";\n  ```\n\n- Only the following database types are supported: \"MariaDB\" | \"MongoDB\" | \"MySQL\" | \"PostgreSQL\" | \"SQLite\"\n  - Maria, MySQL, PostgreSQL Options\n    - database [string] (Required)\n    - host [string] (Required)\n    - username [string] (Required)\n    - password [string] (Required)\n    - port [number] (Optional)\n  - MongoDB Options\n    - uri [string] (Required)\n    - database [string] (Required)\n  - SQLite Options\n    - filepath [string] (Required)\n\n```ts\n/** Example with MongoDB */\nawait createDb({\n  connector: \"MongoDB\",\n  uri: 'mongodb://127.0.0.1:27017',\n  database: 'test'\n});\n\nconst serve = new Server(ListenOptions, FTPServerOptions);\n\nfor await (const connection of serve) {\n  const { awaitUsername, awaitLogin } = connection;\n  let user: Model;\n  /** Waiting to receiving username from connection */\n  awaitUsername.then(({ username, resolveUsername }: UsernameResolvable) =\u003e {\n    /** Find user in database */\n    const found = await Users.where('username', username).get();\n    if ((found instanceof Array \u0026\u0026 found.length === 0) || !found) return resolveUsername.reject(\"Incorrect username!\");\n    user = (found instanceof Array) ? found[0] : found;\n    resolveUsername.resolve();\n  });\n  /** Waiting to receiving password from connection and finalize the user authenticate */\n  awaitLogin.then(async ({ password, resolvePassword }: LoginResolvable) =\u003e {\n    if (!user) return resolvePassword.reject(\"User not found!\");\n    if (! await verify(password, (user.password as string))) return resolvePassword.reject(\"Wrong password!\");\n    const { root, uid, gid } = user;\n    resolvePassword.resolve({ root: (root as string), uid: (uid as number), gid: (gid as number) });\n  });\n}\n```\n\n## Log example\n\n![output_example](./assets/example_log.gif)\n\n* * *\n\n## Deno Dependencies\n\n- ### [Deno](https://deno.land)\n\n  - [async](https://deno.land/std@0.95.0/async)\n  - [io](https://deno.land/std@0.95.0/io)\n  - [path](https://deno.land/std@0.95.0/path)\n  - [fs](https://deno.land/std@0.95.0/fs)\n  - [datetime](https://deno.land/std@0.96.0/datetime)\n\n- ### [getport](https://deno.land/x/getport)\n\n- ### [cliffy](https://deno.land/x/cliffy)\n\n- ### [scrypt](https://deno.land/x/scrypt)\n\n- ### [denodb](https://deno.land/x/denodb)\n\n## [List of FTP commands](https://en.wikipedia.org/wiki/List_of_FTP_commands)\n\nSee [COMMANDS.md](COMMANDS.md)\n\n## Contributing\n\nSee [CONTRIBUTING.md](CONTRIBUTING.md)\n\n## References\n\n- [Ftp](https://cr.yp.to/ftp.html)\n- [Ftp commands](https://en.wikipedia.org/wiki/List_of_FTP_commands)\n- [Ftp reply codes](https://en.wikipedia.org/wiki/List_of_FTP_server_return_codes)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevartsite%2Fdftps","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevartsite%2Fdftps","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevartsite%2Fdftps/lists"}