npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@huxy/fss

v0.0.5

Published

node.js file system

Downloads

10

Readme

文件管理系统

基于 node.jsfs 模块搭建可视化文件管理系统。实现文件(夹)的增删改查功能。

update1

使用

安装:

npm i @huxy/fss

使用:

import fss from '@huxy/fss';
import configs from './configs/index.js';

const {rootpath, MAXSIZE} = configs;

const apis = fss(rootpath);

指定根目录 rootpath,默认为 '/'

api 示例

接口列表

const apis = [
  {
    name: 'readdir',
    url: '/fs/readdir',
    method: 'post',
  },
  {
    name: 'readfile',
    url: '/fs/readfile',
    method: 'post',
  },
  {
    name: 'openfile',
    url: '/fs/openfile',
    method: 'post',
  },
  {
    name: 'mkdir',
    url: '/fs/mkdir',
    method: 'post',
  },
  {
    name: 'touch',
    url: '/fs/touch',
    method: 'post',
  },
  {
    name: 'copyfile',
    url: '/fs/copyfile',
    method: 'post',
  },
  {
    name: 'movefile',
    url: '/fs/movefile',
    method: 'post',
  },
  {
    name: 'rmfile',
    url: '/fs/rmfile',
    method: 'post',
  },
  {
    name: 'rnfile',
    url: '/fs/rnfile',
    method: 'post',
  },
];

读取文件夹

readdir(path)

返回当前目录下的文件信息。

export const readdir = async (req, res) => {
  const {path} = req.body;
  try {
    const result = await apis.readdir(path);
    res.status(200).send({result});
  } catch (error) {
    res.status(500).send({message: error.message});
  }
};

diraction

获取文件信息

readfile(path)

export const readfile = async (req, res) => {
  const {path} = req.body;
  try {
    const result = await apis.readfile(path);
    res.status(200).send({result});
  } catch (error) {
    res.status(500).send({message: error.message});
  }
};

detail

读取文件内容

openfile(path)

export const openfile = async (req, res) => {
  const {path} = req.body;
  try {
    const result = await apis.openfile(path);
    res.status(200).send({result});
  } catch (error) {
    res.status(500).send({message: error.message});
  }
};

update

新建文件夹

mkdir(path, override)

export const mkdir = async (req, res) => {
  const {path, override} = req.body;
  try {
    await apis.mkdir(path, override);
    res.status(200).send({message: '操作成功!'});
  } catch (error) {
    res.status(500).send({message: error.message});
  }
};

adddir

新建文件

touch(path, override, data)

export const touch = async (req, res) => {
  const {path, override, data} = req.body;
  try {
    await apis.touch(path, override, data);
    res.status(200).send({message: '操作成功!'});
  } catch (error) {
    res.status(500).send({message: error.message});
  }
};

addfile

拷贝文件(夹)

copyfile(src, dst)

export const copyfile = async (req, res) => {
  const {src, dst} = req.body;
  try {
    await apis.copyfile(src, dst);
    res.status(200).send({message: '操作成功!'});
  } catch (error) {
    res.status(500).send({message: error.message});
  }
};

fileaction

移动文件(夹)

movefile(src, dst)

export const movefile = async (req, res) => {
  const {src, dst} = req.body;
  try {
    await apis.movefile(src, dst);
    res.status(200).send({message: '操作成功!'});
  } catch (error) {
    res.status(500).send({message: error.message});
  }
};

move

删除文件(夹)

rmfile(path)

export const rmfile = async (req, res) => {
  const {path} = req.body;
  try {
    await apis.rmfile(path);
    res.status(200).send({message: '操作成功!'});
  } catch (error) {
    res.status(500).send({message: error.message});
  }
};

delete

重命名文件(夹)

rnfile(path, newpath)

export const rnfile = async (req, res) => {
  const {path, newpath} = req.body;
  try {
    await apis.rnfile(path, newpath);
    res.status(200).send({message: '操作成功!'});
  } catch (error) {
    res.status(500).send({message: error.message});
  }
};

rename