我正在尝试分离我的项目并将逻辑保留为我最终将发布的单独组件。现在,在我这样做之前,我想将其组织如下:
project-aproject-bReact 应用程序的 .tsx 组件将从 的project-a.ts 文件中提取。
我已经在project-b 中继续并运行了yarn add ../project-a。这会将库作为依赖项安装。然后,我导入 .ts 文件,我的代码编辑器能够很好地查看所有类型和定义。伟大的!
当我运行应用程序时,Webpack 抱怨:
./node_modules/project-a/src/calc.ts 2:7
Module parse failed: Unexpected token (2:7)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
|
> export enum Position {
| Inner = 0,
| Outer = 1
Run Code Online (Sandbox Code Playgroud)
我不明白为什么它不将文件解析为 .ts。整个 React 应用程序是使用 TypeScript …
我想知道是否有一种"正确"的方式来监听Angular上的cookie更改?如果我可以根据他们的新值监听和更改模型中的值,那将是非常棒的.
谢谢.
我想知道在Heroku上设置时钟进程的最佳方法是什么.我的应用程序完全由Node构建,我计划使用node-schedule来指定我的日程安排.
我的问题是:时钟进程本身是否应该触发我的cron进程中的事件并在它自己分配的dyno中运行它们?Heroku似乎表明你应该使用一个工人来处理这个问题.在那种情况下,我想知道如何让我的时钟进程告诉工人运行特定的程序?
我一直在阅读Python方法来执行此操作,看起来它们只是在同一个dyno中触发进程.
谢谢.
我一直在玩几种不同的链接功能集合的方式,似乎找不到我特别喜欢的方法.以下是我最后决定但仍然不热衷的事情.
有人可以提出更清洁,更简洁的模式吗?我不想选择Async.js或库.
[
this.connectDatabase.bind(this),
this.connectServer.bind(this),
this.listen.bind(this)
].reduce(
(chain, fn) => {
let p = new Promise(fn);
chain.then(p);
return p;
},
Promise.resolve()
);
Run Code Online (Sandbox Code Playgroud)
PS.任何其他提示都受到欢迎.
我在将多边形插入表结构时遇到问题.我对PostGIS比较陌生,所以我可能会犯这个非常业余的错误.
我的表设置为"Regions",我正在为我的几何添加一列:
"SELECT AddGeometryColumn(" +
"'public', 'Regions', 'geom', 4326, 'POLYGON', 2" +
");"
Run Code Online (Sandbox Code Playgroud)
根据我的阅读,这将柱子几何设置为接受WGS-83作为我的投影标准.我正在使用GeoJSON插入我的多边形,因为它对我来说是最简单的选择.这是我的更新声明的一个示例:
UPDATE "Regions"
SET geom = ST_GeomFromGeoJSON(
'{"type":"Polygon","coordinates":[[[-114.017347,51.048005],[-114.014433,51.047927],[-114.005899,51.045381],[-114.001598,51.04509],[-114.001631,51.055109],[-114.01618,51.055062],[-114.016949,51.056508],[-114.016181,51.056511],[-114.01659,51.057251],[-114.017318,51.057237],[-114.018672,51.059928],[-114.020528,51.0593],[-114.023615,51.059311],[-114.021148,51.055829],[-114.018807,51.052583],[-114.017347,51.048005]]]}'
)
WHERE id = 'ab8326c0-beb3-11e4-89eb-b3372c283c42'
Run Code Online (Sandbox Code Playgroud)
我从查询中得到的回复是:
{ [SequelizeDatabaseError: Geometry SRID (0) does not match column SRID (4326)]
name: 'SequelizeDatabaseError',
message: 'Geometry SRID (0) does not match column SRID (4326)',
parent:
{ [error: Geometry SRID (0) does not match column SRID (4326)]
name: 'error',
length: 121,
severity: 'ERROR',
code: '22023',
detail: undefined,
hint: undefined,
position: undefined,
internalPosition: undefined,
internalQuery: undefined, …Run Code Online (Sandbox Code Playgroud) 我编写了一个应用程序来查找本地机构并通过RESTful API提供它们.我的堆栈是:express,express-resource和mongoose.这是我的模型示例:
var PlaceSchema = new mongoose.Schema(
{
name: {
type: String,
required: true
},
geolocation: {
lat: Number,
lng: Number
},
address: {
type: String
}
}
);
PlaceSchema.index({
geolocation: '2d'
});
Run Code Online (Sandbox Code Playgroud)
我已经检查了几次,我的lon/lat值正确存储在db中,所以没有任何数据错误.
然后我运行查询以获取具有特定查询值的数据:
mongoose.connection.db.executeDbCommand(
{
geoNear: 'places',
near: [
parseFloat(req.body.lat),
parseFloat(req.body.lng)
],
num: limit,
query: {
// Some additional queries that
// don't impact the geo results.
},
spherical: true,
distanceMultiplier: 6371, // converting results to km
maxDistance: distance / 6371,
},
function(err, result)
{
res.send(200, {
status: …Run Code Online (Sandbox Code Playgroud) 我在同时使用 Cobra 和 Viper 时遇到问题。这就是我正在做的:
var options util.Config = util.Config{}
var rootCmd = &cobra.Command{
Use: "test [command] [subcommands]",
Run: func(cmd *cobra.Command, args []string) {
if err := server.Run(); err != nil {
l.Fatal(err)
}
},
}
// initConfig helps initialise configuration with a stated path
func initConfig() {
if options.Path != "" {
viper.SetConfigFile(options.Path)
}
viper.AutomaticEnv()
if err := viper.ReadInConfig(); err != nil {
fmt.Println("Could not use config file: ", viper.ConfigFileUsed())
}
}
func init() {
cobra.OnInitialize(initConfig)
rootCmd.PersistentFlags().StringVarP(&options.Path, "config", "n", …Run Code Online (Sandbox Code Playgroud) geolocation ×2
geospatial ×2
node.js ×2
angularjs ×1
cookies ×1
es6-promise ×1
go ×1
go-cobra ×1
heroku ×1
mongodb ×1
mongoose ×1
postgis ×1
postgresql ×1
reactjs ×1
sequelize.js ×1
typescript ×1
webpack ×1