我在我的应用程序中使用API.我目前从java界面管理API密钥
public interface APIContract {
//The API KEY MUST NOT BE PUBLISH. It is possible to generate a new one for free from www.themoviedb.org
//Remove before commit !!!
String API_KEY = "abcdefghijklmnopqrstuvwxyz";
/...
}
Run Code Online (Sandbox Code Playgroud)
这样做.我可以使用APIContract.API_KEY
,但正如您在注释中看到的那样,如果我使用git和公共存储库(我不想发布此密钥),这是不安全的.
所以这是我的问题:是否可以将此密钥移动到另一个我可以从我的应用程序轻松访问但不会被提交的地方?
我发现这个线程使用gradle存储密钥,但我需要提交build.gradle
文件,因此它不能完成这项工作.
有人知道如何解决这个问题吗?我没有在stackoverflow中发现类似的问题,但也许我错过了一些东西
编辑
我喜欢在任何Java代码之外移动密钥的想法,因为其他人(可能是非技术人员)可以轻松管理自己的密钥.我正在考虑使用gradle文件settings.gradle
.
尝试根据与数据一起传递的参数呈现不同的组件.如果我使用常规或React.createElement(Item) - 它工作正常,但所有其他选项都失败.
http://jsfiddle.net/zeen/fmhhtk5o/1/
var React = window.React;
var data = {items: [
{ itemClass: 'Item', id: 1, contentsHTML: '', text: 'Item 1'},
{ itemClass: 'Item', id: 2, contentsHTML: '', text: 'Item 2'},
{ itemClass: 'Item', id: 3, contentsHTML: '', text: 'Item 3'},
{ itemClass: 'Item', id: 4, contentsHTML: '', text: 'Item 4'},
{ itemClass: 'Item', id: 5, contentsHTML: '', text: 'Item 5'}
]};
var MyCatalog = React.createClass({
getInitialState: function() {
return { data: { items: [] } };
}, …
Run Code Online (Sandbox Code Playgroud) 我正在尝试用来react-leaflet
显示地图.我使用这个小提琴的代码正在工作,但在我的电脑上我有这个输出
这是我的代码:
DeviceMap.js
import React from 'react'
import { Map, Marker, Popup, TileLayer } from 'react-leaflet';
export class DeviceMap extends React.Component {
constructor() {
super();
this.state = {
lat: 51.505,
lng: -0.09,
zoom: 13,
};
}
render() {
const position = [this.state.lat, this.state.lng];
return (
<Map center={position} zoom={this.state.zoom} scrollWheelZoom={false}>
<TileLayer
attribution='© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
url='http://{s}.tile.osm.org/{z}/{x}/{y}.png'
/>
<Marker position={position}>
<Popup>
<span>A pretty CSS3 popup. <br/> Easily customizable.</span>
</Popup>
</Marker>
</Map>
);
}
}
export default DeviceMap
Run Code Online (Sandbox Code Playgroud)
DeviceTabs.js …
我正在尝试使用 docker compose 设置一些集成测试。我正在使用 docker compose 来启动 postgres 数据库和 nodejs 服务器。然后我使用 jest 对服务器运行 http 请求。
由于某些原因,我无法解释所有 SQL 查询(即使是最简单的查询)都非常慢(+ 1 秒)。
听起来像是两个容器之间的通信问题,但我无法发现它。难道我做错了什么?
这是我的docker-compose.yml
文件。服务器只是一个简单的express应用程序
version: "3.9"
services:
database:
image: postgres:12
env_file: .env
volumes:
- ./db-data:/var/lib/postgresql/data
healthcheck:
test: pg_isready -U test_user -d test_database
interval: 1s
timeout: 10s
retries: 3
start_period: 0s
server:
build: .
ports:
- "8080:8080"
depends_on:
database:
condition: service_healthy
env_file: .env
environment:
POSTGRES_HOST: database
NODE_ENV: test
init: true
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/healthcheck"]
interval: 1s
timeout: 10s
retries: …
Run Code Online (Sandbox Code Playgroud) 我有这张桌子
设备
id name groupId serviceId
791 Mamie Ortega 205 1832
Run Code Online (Sandbox Code Playgroud)
组
id serviceId
205 1832
Run Code Online (Sandbox Code Playgroud)
记录
id date deviceId
792 2017-07-13 13:30:19.740360 784
793 2017-07-13 13:30:19.742799 784
Run Code Online (Sandbox Code Playgroud)
警报
id status deviceId
241 new 784
242 new 784
Run Code Online (Sandbox Code Playgroud)
我正在运行此查询
SELECT device.id, device.name, COUNT(records.id) AS "last24HMessagesCount", COUNT(alarms.id) AS "activeAlarmsCount"
FROM device
INNER JOIN "group" AS "group" ON "device"."groupId" = "group"."id" AND "group"."id" = '205'
LEFT OUTER JOIN "record" AS "records" ON "device"."id" = "records"."deviceId" AND "records"."date" > '2017-07-12 11:43:02.838 +00:00'
LEFT …
Run Code Online (Sandbox Code Playgroud) 我正在写一些测试,enzyme
但我有一些奇怪的行为.这是我的测试:
import React from 'react'
import { TypeTable } from 'routes/Type/components/TypeTable'
import { shallow } from 'enzyme'
import { Table } from 'react-toolbox'
// ...
let _props, _wrapper
beforeEach(() => {
_props = {
getTypes: sinon.spy(),
types: [
{ name: 'type 1'},
{ name: 'type 2'}
]
}
_wrapper = shallow(<TypeTable {..._props} />)
})
it('Should render a <Table>', () => {
expect(_wrapper.is(Table)).to.be.true
})
it('should render 2 rows', () => {
expect(_wrapper.find('tbody').find('tr')).to.have.length(2)
})
Run Code Online (Sandbox Code Playgroud)
第一次测试正在进行中.第二个不工作(断言失败:expected { Object (root, unrendered, …
我有这个档案
routing.ts
class RouteConfig {
// Some implementation
}
Run Code Online (Sandbox Code Playgroud)
我这样使用
app.module.ts
angular.module("ApplicationsApp", [
"ApplicationsApp.Services",
"ApplicationsApp.Clients",
"ApplicationsApp.Application"])
.config(RouteConfig);
Run Code Online (Sandbox Code Playgroud)
然后,我使用导入两个先前的文件
索引
import "./scripts/routing.ts";
import "./scripts/app.module.ts"";
Run Code Online (Sandbox Code Playgroud)
我正在使用webpack
and ts-loader
并且index.ts
是入口点之一。构建成功,但是当我运行它时,出现此错误
app.module.ts:5 Uncaught ReferenceError: RouteConfig is not defined
at Object.<anonymous> (app.module.ts:5)
at __webpack_require__ (bootstrap 755a82fd7c11e301b6c1:676)
at fn (bootstrap 755a82fd7c11e301b6c1:87)
at Object.<anonymous> (index.ts:4)
at __webpack_require__ (bootstrap 755a82fd7c11e301b6c1:676)
at fn (bootstrap 755a82fd7c11e301b6c1:87)
at Object.defineProperty.value (events.js:302)
at __webpack_require__ (bootstrap 755a82fd7c11e301b6c1:676)
at logLevel (bootstrap 755a82fd7c11e301b6c1:722)
at main.min.js:726
Run Code Online (Sandbox Code Playgroud)
我给的配置ts-loader
看起来像
{
configFile: paths.resolveOwn('config/tsconfig.json'),
compilerOptions: { …
Run Code Online (Sandbox Code Playgroud) javascript ×3
reactjs ×3
postgresql ×2
android ×1
docker ×1
enzyme ×1
node.js ×1
sql ×1
ts-loader ×1
typescript ×1
webpack ×1