Giter Site home page Giter Site logo

api's Introduction

api

Build Status GPL-3.0

服务端,需配合 mtdhb/get 使用

Environment

MySQL 5.7

Redis 4.0.9

JDK 1.8+

Nginx 1.12.2

MySQL

CREATE DATABASE api;
USE api;
\. 绝对路径ddl.sql

Redis

默认配置

Java

Configuration

DATASOURCE

src/main/resources/application-prod.yml

spring:
    datasource:
        url: jdbc:mysql://127.0.0.1:3306/api?useUnicode=true&characterEncoding=UTF-8&useSSL=false
        username: 你的数据库用户名
        password: 你的数据库密码

EMAIL

src/main/resources/mail0.properties

mail.transport.protocol=smtp
mail.smtp.host=你的邮箱的 SMTP 服务器地址
mail.smtp.socketFactory.class=javax.net.ssl.SSLSocketFactory
mail.smtp.socketFactory.port=465
mail.smtp.auth=true

# Custom
com.mtdhb.mail.personal=\u6BCF\u5929\u5927\u7EA2\u5305
com.mtdhb.mail.user=你的邮箱账号
com.mtdhb.mail.password=你的邮箱密码

支持多邮箱配置,你只需在 src/main/resources/ 目录下新增 mail*.properties 并保证文件名最后的索引数字是连续递增的即可。

Package

mvn clean package

Run

# 开发
java -jar target/api-1.0.0.jar --spring.profiles.active=dev
# 生产
nohup java -XX:+HeapDumpOnOutOfMemoryError -jar target/api-1.0.0.jar --spring.profiles.active=prod > target/console.log 2>&1 &

Shutdown

curl -X POST http://127.0.0.1:8081/actuator/shutdown

Nginx

部分 nginx 配置(与本站服务器不完全一致,删减了部分配置,仅供参考)

map $http_origin $corsHost {
    default 0;
    "~https://你的网页域名.com" https://你的网页域名.com;
    "~http://localhost:4001" http://localhost:4001;
    "~http://127.0.0.1:4001" http://127.0.0.1:4001;
}

server {
    listen 443 ssl default_server;
    server_name 你的API域名;

    add_header Access-Control-Allow-Credentials true;
    add_header Access-Control-Allow-Origin $corsHost;
    add_header Access-Control-Allow-Headers X-User-Token;
    add_header Access-Control-Allow-Methods 'GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS, TRACE';

    expires -1;

    if ($request_method = 'OPTIONS') {
        return 204;
    }

    if ($server_port !~ 443) {
        rewrite ^(/.*)$ https://$host$1 permanent;
    }

    location = /notice.json {
        expires 1m;
        root /存放公告的目录;
    }

    location / {
        proxy_pass http://127.0.0.1:8080;
    }
}

api's People

Contributors

huangdenghe avatar zhuweiyou 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.