Giter Site home page Giter Site logo

serverless-plus / serverless-admin-system Goto Github PK

View Code? Open in Web Editor NEW
12.0 3.0 0.0 221 KB

Serverless Admin System

Home Page: https://sls-admin.yugasun.com/

License: MIT License

JavaScript 61.27% HTML 0.66% Vue 31.82% Shell 0.21% SCSS 6.03%
serverless serverless-framework admin-system serverless-components eggjs vuejs postgresql redis

serverless-admin-system's Introduction

Serverless Admin System

在线体验

使用 Serverless Components 开发的后台管理系统

  1. 安装 CLI
  2. 初始化项目
  3. 配置
  4. 部署
  5. 开发

安装 CLI

在开始之前需要先安装 Serverless CLI 工具

$ npm i serverless -g

初始化项目

Serverless 命令行工具非常方便,可以直接初始化项目模板:

$ serverless init admin-system

安装项目依赖:

$ npm run bootstrap

项目目录介绍

├── backend         后端服务,Egg.js + PostgreSQL + Redis
├── db              Serverless PG,使用 tencent-postgresql 组件部署创建
├── frontend        前端页面,Vue.js + vue-admin-template,项目模板:https://github.com/PanJiaChen/vue-admin-template
├── package.json
├── scripts         项目脚本,主要含有 bootstrap.js 用来自动安装前后端项目依赖
└── vpc             Serverless VPC,使用 tencent-vpc 组件部署,用来创建腾讯云私有网络

配置

复制项目根目录的 .env.example 文件为 .env,内容如下:

# .env
TENCENT_SECRET_ID=xxx
TENCENT_SECRET_KEY=xxx

REGION=ap-guangzhou
ZONE=ap-guangzhou-2

注意:TENCENT_SECRET_IDTENCENT_SECRET_KEY 可以到 腾讯云 CAM 控制台 获取。

由于后端服务使用 redis 来存储接口鉴权 Token,所以我们还需要给后端项目配置 redis 建连参数,复制 backend 目录的 .env.example.env,然后配置自己的 redis 服务参数:

REDIS_HOST=xxx
REDIS_PORT=xxx
REDIS_PASSWORD=xxx

此项目也支持 Authing 第三方登录,如果你不需要可以直接忽略,如果需要,可以到 Authing 控制台 获取配置,然后添加到 backend/.env 中:

REDIS_HOST=xxx
REDIS_PORT=xxx
REDIS_PASSWORD=xxx

# authing 应用配置
AUTHING_APPID=xxx
AUTHING_APPSECRET=xxx

本地开发

后端服务使用的的数据库均使用本地 Docker 来启动,所以本地开发时,需要先启动 docker 服务:

$ npm run docker:up

启动后端服务

$ npm run dev:be

启动前端开发

$ npm run dev:fe

部署

在部署业务代码之前,我们需要先将后端的 node_modules 文件夹部署为层:

$ npm run deploy:be:layer

注意:在层部署成功后,如果后端项目的 node_modules 没有修改,可以不用再次执行层部署。

部署项目代码:

$ npm run deploy

初始化数据库

部署成功后,我们就可以获得数据库相关参数,其中 postgresql 输出的 public 对象中的参数是用来公网访问的。

在访问服务前,我们还需要同步数据库表结构,修改 database/config.js 中的 production 对象的配置为 postgresql 输出的 public 对象中的参数值,

相关参数对应关系:

postgresql.public 输出 database/config.jsproduction 参数
host host
port post
user username
password password
dbname database

然后我们执行:

$ npm run db:migrate

就可以自动帮助初始化数据库,包括表结构和测试数据。

License

MIT License

Copyright (c) 2020 Serverless Plus

serverless-admin-system's People

Contributors

yugasun avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.