# sdk_npm_z

> nodejs sdk包发布为npm包

Latest version **1.0.2** (published 2022-07-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install sdk_npm_z
pnpm add sdk_npm_z
yarn add sdk_npm_z
bun add sdk_npm_z
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2022-07-21 |
| First published | 2022-07-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 4.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | zhangxiaoying1 |

## Links

- npm: https://www.npmjs.com/package/sdk_npm_z
- Repository: https://github.com/neohan666/sdk
- Homepage: https://github.com/neohan666/sdk#readme
- Issues: https://github.com/neohan666/sdk/issues
- npm.io page: https://npm.io/package/sdk_npm_z

## Dependencies (3)

- [morgan](https://npm.io/package/morgan.md) ^1.10.0
- [express](https://npm.io/package/express.md) ^4.18.1
- [aliyun-sdk](https://npm.io/package/aliyun-sdk.md) ^1.12.5

## Recent versions

- 1.0.2 (latest) — 2022-07-21
- 1.0.1 — 2022-07-21
- 1.0.0 — 2022-07-20

## README

# 1、Node.js SDK概述

> &emsp;&emsp;日志服务Node.js SDK封装了日志服务的所有API接口。您可以通过日志服务Node.js SDK方便地调用日志服务的所有API接口。


## 示例代码
日志服务Node.js SDK提供丰富的示例代码，方便参考或直接使用。

**示例代码包括以下内容：**
```
All.js	写入日志、查询日志、查询Logstore、获取日志分布情况等相关示例。    
BatchGetLogs.js	批量查询日志相关示例。    
CreateLogStore.js	创建和修改日志库信息的相关示例。    
GetLogs.js	使用GetLogs查询日志的相关示例。      
PutLogs.js	使用PutLogs写入日志的相关示例。      
Shard.js	管理Shard相关示例。 

```
# 2、安装Node.js SDK
> &emsp;&emsp;使用Node.js SDK进行日志服务各类操作前，您需要安装Node.js SDK。以下介绍Node.js SDK的安装方法。      

# 安装SDK       
**1）.创建项目目录，并进入该目录。**
**2）.执行以下命令初始化。**
```
npm init
```
**按照向导提示进行配置。初始化完成后，会自动创建一个package.json文件。其文件内容示例以下：**
```
{
  "name": "sls_node",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC"
}
```
**3）、执行以下命令安装Node.js SDK。**
```
npm install aliyun-sdk
```
**执行完成后，package.json文件已注入aliyun-sdk信息。其文件内容示例以下：**
```
{
  "name": "sls_node",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "aliyun-sdk": "^1.12.3"
  }
}
```
**4）、搭建项目。本文以使用Express搭建项目为例。**
**（1）执行以下命令安装Express。**
```
npm install express
```
**更多信息，请参见installing。**
**（2）执行以下命令安装morgan。**
```
npm install morgan
```
**（3）创建app.js文件并写入以下代码。**
```
var express = require('express')
var morgan = require('morgan')
var app = express()
const logger = morgan(function (tokens, req, res) {
  return [
    tokens.method(req, res),
    tokens.url(req, res),
    tokens.status(req, res),
    tokens.res(req, res, 'content-length'), '-',
    tokens['response-time'](req, res), 'ms'
  ].join(' ')
})
app.use(logger)
app.get('/', (req, res) => res.send('Hello World!'))
app.listen(3000, () => console.log('Example app listening on port 3000!'))
```
**（4）执行以下命令启动项目。**
```
node app.js
```
**完成后，返回以下结果。**
```
Example app listening on port 3000！
```

---
_Source: https://npm.io/package/sdk_npm_z · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
